code wiki / (root) / nx_rsa2048_mod_exp.nx

nx_rsa2048_mod_exp.nx

buildroot/runtime/nx_rsa2048_mod_exp.nx

2485 B81 linesdepth 5pulls 5 transitivereach 544 importersview sourcekind tooltopic rsa2048
docsdependenciesstructsconstsfunctions

about

nx_rsa2048_mod_exp.nx -- RSA mod-exp s^e mod n for 2048-bit modulus. For RSA-PKCS#1 v1.5 signature verification, the public exponent e is small (commonly 65537 = 2^16 + 1). We implement square-and- multiply MSB-first over the bits of e expressed as an i64 (up to 64-bit exponent supported). For e = 65537 = 0x10001, bits 16 and 0 are set; the loop runs max(bit_length(e)) iterations. API: rsa2048_mod_exp(out, s, e: i64, n) -- out = s^e mod n Caller responsibilities: - s < n (range-checked here; returns nonzero verdict if s >= n) - n is 2048-bit with top bit set - e fits in i64 (true for all Web PKI: e is either 3, 17, 65537) license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_8017 lineage_id: nishi_rsa2048_mod_exp_q10

dependencies 4 imports · 5 importers

nx_syscalls.nx nx_u2048.nx nx_u2048_mul.nx nx_rsa2048_mod.nx nx_rsa2048_mod_exp.nx nx_rsa2048_mont_gate.nx nx_rsa_pkcs1_v1_5_sha256.nx nx_rsa_pkcs1_v1_5_sha384.nx nx_rsa_pkcs1_v1_5_sha512.nx nx_rsa_pss_sha256.nx

imports: nx_syscalls.nxnx_u2048.nxnx_u2048_mul.nxnx_rsa2048_mod.nx

imported by: nx_rsa2048_mont_gate.nxnx_rsa_pkcs1_v1_5_sha256.nxnx_rsa_pkcs1_v1_5_sha384.nxnx_rsa_pkcs1_v1_5_sha512.nxnx_rsa_pss_sha256.nx

structs

none

consts

34const NX_RSA2048_MOD_EXP_OK: i64 = 1
35const NX_RSA2048_MOD_EXP_S_OUT_OF_RANGE: i64 = 2

functions

38func rsa2048_highbit_i64(e: i64) -> i64
called by 1: rsa2048_mod_exp
49func rsa2048_mod_exp(out: *i64, s: *i64, e: i64, n: *i64) -> i64
79func main() -> i64