code wiki / (root) / nx_rsa_pkcs1_v1_5_sha256_4096.nx

nx_rsa_pkcs1_v1_5_sha256_4096.nx

buildroot/runtime/nx_rsa_pkcs1_v1_5_sha256_4096.nx

5093 B123 linesdepth 7pulls 16 transitivereach 527 importersview sourcekind tooltopic rsa
docsdependenciesstructsconstsfunctions

about

nx_rsa_pkcs1_v1_5_sha256_4096.nx -- RSA-PKCS#1 v1.5 signature verify with SHA-256 hash, for RSA-4096 keys. Parallel to nx_rsa_pkcs1_v1_5_sha256 (the RSA-2048 variant); kept as a separate module rather than parameterizing the existing module so the existing 2048 callers continue to compile unchanged. RFC 8017 ยง8.2.2 RSASSA-PKCS1-v1_5-VERIFY (k=512 bytes for RSA-4096): 1. s -> m = s^e mod n (4096-bit RSA modular exponentiation) 2. Encode message into EM_test: EM_test = 0x00 || 0x01 || PS (FF*458) || 0x00 || T || H where T = SHA-256 DigestInfo DER prefix (19 bytes): 30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 and H = SHA-256(message) (32 bytes). PS_LEN = 512 - 3 - 19 - 32 = 458 bytes of 0xFF. 3. Convert m to 512-byte big-endian EM. 4. Compare EM == EM_test byte-by-byte. API: rsa_pkcs1_v1_5_sha256_4096_verify(msg, msg_len, sig_bytes, n_4096, e_i64) -> verdict Sealed verdict (parallel to 2048-variant; same shape so cert-chain verifier can map verdicts uniformly): NX_RSA_PKCS1_V15_4096_OK valid signature NX_RSA_PKCS1_V15_4096_S_OUT_OF_RANGE s_int >= n NX_RSA_PKCS1_V15_4096_BAD_PAD padding mismatch NX_RSA_PKCS1_V15_4096_HASH_MISMATCH trailing 32 bytes != SHA-256(msg) Composes: - sha256_digest (already shipped) - u4096_load_be / u4096_store_be (stone 1) - rsa4096_mod_exp (stone 3) - rsa_pkcs1_sha256_di_byte (shared with 2048 variant) Unblocks: L11 step 2d -> 2e (LE E7 -> ISRG Root X1 chain validates; nx_acme daemon can drive state machine end-to-end against LE). license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_8017 + nist/fips_180_4 lineage_id: nishi_rsa_pkcs1_v1_5_sha256_4096_q1

dependencies 6 imports · 3 importers

nx_syscalls.nx nx_sha256.nx nx_u4096.nx nx_rsa4096_mod_exp.nx nx_rsa4096_mont.nx nx_rsa_pkcs1_v1_5_sha256.nx nx_rsa_pkcs1_v1_5_sha256_4096. nx_rsa_pkcs1_v1_5_sha256_4096_real nx_rsa_pkcs1_v1_5_sha256_4096_test nx_x509_verify_rsa_pkcs1_sha256_40

imports: nx_syscalls.nxnx_sha256.nxnx_u4096.nxnx_rsa4096_mod_exp.nxnx_rsa4096_mont.nxnx_rsa_pkcs1_v1_5_sha256.nx

imported by: nx_rsa_pkcs1_v1_5_sha256_4096_real_test.nxnx_rsa_pkcs1_v1_5_sha256_4096_test.nxnx_x509_verify_rsa_pkcs1_sha256_4096.nx

structs

none

consts

48const NX_MAGIC_4096: i64 = 4096
50const NX_RSA_PKCS1_V15_4096_OK: i64 = 1
51const NX_RSA_PKCS1_V15_4096_S_OUT_OF_RANGE: i64 = 2
52const NX_RSA_PKCS1_V15_4096_BAD_PAD: i64 = 3
53const NX_RSA_PKCS1_V15_4096_HASH_MISMATCH: i64 = 4
54const NX_RSA_PKCS1_V15_4096_VERDICT_N: i64 = 5

functions

56func rsa_pkcs1_v1_5_4096_verdict_is_valid(v: i64) -> i64
called by 1: main
71func rsa_pkcs1_v1_5_sha256_4096_verify(msg: *u8, msg_len: i64,
121func main() -> i64