code wiki / _hdl_build / nx_rsa2048_mod_exp_big.nx

nx_rsa2048_mod_exp_big.nx

buildroot/runtime/_hdl_build/nx_rsa2048_mod_exp_big.nx

9567 B213 linesdepth 6pulls 6 transitivereach 6 importersview sourcekind tooltopic rsa2048
docsdependenciesstructsconstsfunctions

about

nx_rsa2048_mod_exp_big.nx -- F103e RUNG 4: modular exponentiation with a FULL-WIDTH exponent. THE GAP, found by reading the signature rather than the filename: the estate's `rsa2048_mod_exp(out, s, e: i64, n)` takes the exponent as an **i64**, and its own header says so plainly -- "e fits in i64 (true for all Web PKI: e is either 3, 17, 65537)". That is correct and sufficient for VERIFICATION, where the public exponent is tiny. It is structurally unable to do either of the two things F103e needs next: * RSA SIGNING: s = m^d mod n, where the private exponent d is ~2048 bits. * MILLER-RABIN: a^d mod n, where d = (n-1)/2^r is ~1024 bits -- i.e. RSA KEYGEN. ★★★★★★A LIBRARY NAMED FOR AN OPERATION MAY IMPLEMENT ONLY THE DIRECTION ITS AUTHOR NEEDED. "The estate has RSA" was true and useless; it has RSA-verify. The symbol table said i64 and the filename did not. This is the same square-and-multiply as the incumbent, MSB-first, but walking the bits of a u2048 exponent instead of an i64. It deliberately does NOT re-implement the modular multiply -- it calls the SAME `rsa2048_mul_mod` the incumbent calls, so there is exactly one modmul in the estate. ★THE ORACLE IS THE INCUMBENT: for every exponent that fits in an i64, this function must agree with `rsa2048_mod_exp` BIT FOR BIT. The teeth check e = 3, 17, 65537 and 2^63-1 against it, then exercise an exponent NO i64 can hold -- the case that motivated the organ and the one the incumbent cannot answer, so it is reported as EXERCISED rather than cross-checked. Usage: nx_rsa2048_mod_exp_big selftest Exit: 0 GREEN | 1 RED. Log -> knowledge/status/nishi_os.log, verdict= LAST. license_tier: ORIGINAL

dependencies 5 imports · 6 importers

nx_syscalls.nx nx_u2048.nx nx_u2048_mul.nx nx_rsa2048_mod.nx nx_rsa2048_mod_exp.nx nx_rsa2048_mod_exp_big.nx nx_authenticode_sign.nx nx_efivars_enrol.nx nx_rsa_keygen.nx nx_rsa_pkcs1_sign.nx nx_u2048_millerrabin.nx nx_x509_emit.nx

imports: nx_syscalls.nxnx_u2048.nxnx_u2048_mul.nxnx_rsa2048_mod.nxnx_rsa2048_mod_exp.nx

imported by: nx_authenticode_sign.nxnx_efivars_enrol.nxnx_rsa_keygen.nxnx_rsa_pkcs1_sign.nxnx_u2048_millerrabin.nxnx_x509_emit.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main meb_selftest u2048_alloc sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mmap ↻ u2048_load_be rsa2048_mod_exp u2048_cmp rsa2048_highbit_i64 u2048_one u2048_zero u2048_alloc ↻ u2048_copy rsa2048_mul_mod u2048_wide_alloc sys_mmap ↻ u2048_mul_wide rsa2048_mod u2048_alloc ↻ u2048_zero ↻ u2048_shl1 u2048_wide_get_bit u2048_sub_with_borrow u2048_cmp ↻ u2048_copy ↻ meb_set_i64

structs

none

consts

31const MEB_MAGIC_65537: i64 = 65537
32const MEB_MAGIC_9223372036854775807: i64 = 9223372036854775807
34const MEB_OK: i64 = 1
35const MEB_S_OUT_OF_RANGE: i64 = 2
36const MEB_BITS: i64 = 2048

functions

38func meb_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: meb_selftest calls 1: sys_write
39func meb_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 }
called by 1: meb_selftest calls 1: sys_write
40func meb_fn(fd: i64, v: i64) -> i64
called by 1: meb_selftest calls 2: sys_mmapsys_write
53func meb_highbit(e: *i64) -> i64
called by 1: rsa2048_mod_exp_big calls 1: u2048_get_bit
63func rsa2048_mod_exp_big(out: *i64, s: *i64, e: *i64, n: *i64) -> i64
86func meb_set_i64(x: *i64, v: i64) -> i64
called by 1: meb_selftest calls 2: sys_mmapu2048_load_be
96func meb_selftest() -> i64
211func main(argc: i64, argv: *i64) -> i64
calls 1: meb_selftest