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 · 12 importers
diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.
imports: nx_syscalls.nxnx_u2048.nxnx_u2048_mul.nxnx_rsa2048_mod.nx
imported by: nx_authenticode_sign.nxnx_efivars_enrol.nxnx_rsa2048_mod_exp_big.nxnx_rsa2048_mont_gate.nxnx_rsa_keygen.nxnx_rsa_pkcs1_sign.nxnx_rsa_pkcs1_v1_5_sha256.nxnx_rsa_pkcs1_v1_5_sha384.nxnx_rsa_pkcs1_v1_5_sha512.nxnx_rsa_pss_sha256.nxnx_u2048_millerrabin.nxnx_x509_emit.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 |
| 79 | func main() -> i64 |