nx_rsa2048_mod_exp.nx
buildroot/runtime/nx_rsa2048_mod_exp.nx
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
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
| 34 | const NX_RSA2048_MOD_EXP_OK: i64 = 1 |
| 35 | const NX_RSA2048_MOD_EXP_S_OUT_OF_RANGE: i64 = 2 |
functions
| 38 | func rsa2048_highbit_i64(e: i64) -> i64 called by 1: rsa2048_mod_exp |
| 49 | func rsa2048_mod_exp(out: *i64, s: *i64, e: i64, n: *i64) -> i64 called by 1: one_case calls 6: u2048_cmprsa2048_highbit_i64u2048_oneu2048_allocu2048_copyrsa2048_mul_mod |
| 79 | func main() -> i64 |