code wiki / _hdl_build / nx_x509_emit.nx
nx_x509_emit.nx
buildroot/runtime/_hdl_build/nx_x509_emit.nx
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
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
| 43 | const XE_MAGIC_65536: i64 = 65536 |
| 44 | const XE_MAGIC_1024: i64 = 1024 |
| 45 | const XE_MAGIC_113549: i64 = 113549 |
| 46 | const XE_MAGIC_20260808: i64 = 20260808 |
| 47 | const XE_MAGIC_65537: i64 = 65537 |
| 48 | const XE_MAGIC_4097: i64 = 4097 |
| 50 | const XE_BUF: i64 = 8192 |
functions
| 52 | func 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 } |
| 53 | func 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 } |
| 54 | func xe_fn(fd: i64, v: i64) -> i64 |
| 66 | func xe_put_len(out: *u8, off: i64, n: i64) -> i64 |
| 77 | func xe_len_size(n: i64) -> i64 |
| 83 | func xe_wrap(out: *u8, off: i64, tag: i64, payload: *u8, plen: i64) -> i64 |
| 93 | func der_oid_from_arcs(out: *u8, off: i64, arcs: *i64, narcs: i64) -> i64 |
| 122 | func xe_algid(out: *u8, off: i64, arcs: *i64, narcs: i64) -> i64 |
| 132 | func xe_name(out: *u8, off: i64, cn: *u8) -> i64 |
| 148 | func xe_spki(out: *u8, off: i64, n: *i64, e: i64) -> i64 |
| 195 | func xe_tbs(out: *u8, off: i64, n: *i64, e: i64, cn: *u8, serial: i64) -> i64 |
| 226 | func x509_emit_selfsigned(out: *u8, n: *i64, d: *i64, e: i64, cn: *u8, serial: i64, |
| 253 | func xe_selftest() -> i64 |
| 385 | func main(argc: i64, argv: *i64) -> i64 |