nx_rsa4096_mont.nx
buildroot/runtime/nx_rsa4096_mont.nx
about
nx_rsa4096_mont.nx -- CIOS Montgomery modular multiplication + modexp for the 4096-bit RSA modulus.
THE FIX (operator 2026-06-23, found by the apm->conductor->drill loop): RSA-2048 got Montgomery
(nx_rsa2048_mont, ~1.5s->few ms), but RSA-4096 NEVER DID -- it still used the slow bit-by-bit
rsa4096_mod_exp (rsa4096_mul_mod = u4096_mul + rsa4096_mod reduction, ~18x per verify). Real Web PKI
chains terminate at an RSA-4096 ROOT (e.g. Let's Encrypt's ISRG Root X1), so the intermediate-under-root
link paid ~242ms (the apm "cert link alg=3" certloop hotspot). This is the 128-limb CIOS Montgomery,
byte-identical to rsa4096_mod_exp (KAT-gated in nx_rsa4096_mont_gate), cutting that link to a few ms.
Adapts nx_rsa2048_mont 64->128 limbs verbatim (CIOS is limb-parametric). Side-channels: verifies PUBLIC
certs, constant-time not required. license_tier: INDEPENDENT_REDERIVE
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_u4096.nxnx_rsa4096_mod.nx
imported by: nx_rsa4096_mont_gate.nxnx_rsa_pkcs1_v1_5_sha256_4096.nx
structs
| none |
consts
| 14 | const NX_MAGIC_4096: i64 = 4096 |
| 16 | const NX_RSA4096_MONT_OK: i64 = 1 |
| 17 | const NX_RSA4096_MONT_S_OUT_OF_RANGE: i64 = 2 |
functions
| 19 | func rsa4096_mont_highbit(e: i64) -> i64 called by 1: rsa4096_mod_exp_mont |
| 26 | func rsa4096_mont_n0inv(n0_full: i64) -> i64 called by 1: rsa4096_mod_exp_mont |
| 40 | func rsa4096_mont_mul(out: *i64, a: *i64, b: *i64, n: *i64, n0inv: i64) -> i64 called by 1: rsa4096_mod_exp_mont calls 5: sys_mmapu4096_cmpu4096_sub_with_borrowu4096_copysys_munmap |
| 90 | func rsa4096_mont_r2(out: *i64, n: *i64) -> i64 called by 1: rsa4096_mod_exp_mont calls 6: sys_mmapu4096_allocrsa4096_modrsa4096_mul_modsys_munmapu4096_free |
| 104 | func rsa4096_mod_exp_mont(out: *i64, s: *i64, e: i64, n: *i64) -> i64 |
| 138 | func main() -> i64 { return 0 } |