code wiki / (root) / nx_rsa_pss_sha256.nx

nx_rsa_pss_sha256.nx

buildroot/runtime/nx_rsa_pss_sha256.nx

4908 B98 linesdepth 6pulls 10 transitivereach 500 importersview sourcekind librarytopic rsa
docsdependenciesstructsconstsfunctions

about

nx_rsa_pss_sha256.nx -- RSASSA-PSS signature VERIFY with SHA-256 (MGF1-SHA-256, salt_len=32), RSA-2048. This is rsa_pss_rsae_sha256 (TLS SignatureScheme 0x0804) -- the scheme TLS 1.3 MANDATES for RSA-cert servers' CertificateVerify (rsa_pkcs1 is NOT allowed for CV). Without it we fail-closed on EVERY RSA-cert TLS-1.3 server (e.g. i.nhentai.net's Cloudflare edge). COMPOSED (Cardinals 15/22): reuses the SAME RSA modexp (rsa2048_mod_exp_mont) + u2048 bignum + sha256_digest as the PKCS#1 verifier; only the EMSA-PSS-VERIFY padding check (RFC 8017 sec 9.1.2) is new. license_tier: INDEPENDENT_REDERIVE genealogy: ietf/rfc_8017 sec_9_1_2

dependencies 5 imports · 2 importers

nx_syscalls.nx nx_sha256.nx nx_u2048.nx nx_rsa2048_mod_exp.nx nx_rsa2048_mont.nx nx_rsa_pss_sha256.nx nx_rsa_pss_sha256_gate.nx nx_tls13_client_verify_cv.nx

imports: nx_syscalls.nxnx_sha256.nxnx_u2048.nxnx_rsa2048_mod_exp.nxnx_rsa2048_mont.nx

imported by: nx_rsa_pss_sha256_gate.nxnx_tls13_client_verify_cv.nx

structs

none

consts

13const NX_RSA_PSS_OK: i64 = 1
14const NX_RSA_PSS_S_OUT_OF_RANGE:i64 = 2
15const NX_RSA_PSS_BAD_PAD: i64 = 3 // EM structure / trailer / masked-bits / DB prefix wrong
16const NX_RSA_PSS_HASH_MISMATCH: i64 = 4 // H != H' (the possession proof fails)
17const NX_RSA_PSS_VERDICT_N: i64 = 5

functions

19func rsa_pss_verdict_is_valid(v: i64) -> i64 { if v < NX_RSA_PSS_OK { return 0 } if v >= NX_RSA_PSS_VERDICT_N { return 0 } return 1 }
22func mgf1_sha256(seed: *u8, seed_len: i64, mask: *u8, mask_len: i64) -> i64
46func rsa_pss_sha256_verify(msg: *u8, msg_len: i64, sig_bytes: *u8, n_2048: *i64, e_i64: i64) -> i64