code wiki / (root) / nx_rsa_pkcs1_v1_5_sha512.nx

nx_rsa_pkcs1_v1_5_sha512.nx

buildroot/runtime/nx_rsa_pkcs1_v1_5_sha512.nx

5178 B133 linesdepth 6pulls 14 transitivereach 2 importersview sourcekind tooltopic rsa
docsdependenciesstructsconstsfunctions

about

nx_rsa_pkcs1_v1_5_sha512.nx -- RSA-PKCS#1 v1.5 signature verify with SHA-512, for RSA-2048 AND RSA-4096 keys. Parallel to nx_rsa_pkcs1_v1_5_sha256{,_4096} and nx_rsa_pkcs1_v1_5_sha384; authored 2026-07-25 because publicreporting.cftc.gov signs its TLS-1.2 ServerKeyExchange with sha512WithRSAEncryption (signature_algorithms hash=6 sig=1) and our TLS-1.2 client REFUSED it by name -- the last thing blocking CFTC Commitments-of-Traders positioning data. Differs from the SHA-384 variant ONLY in: hash = SHA-512 (64 bytes), the DigestInfo DER prefix, and PS length. RSA mod-exp is REUSED verbatim -- no new bignum or padding logic is introduced here. RFC 8017 8.2.2: s -> m = s^e mod n; EM = 00 01 PS(FF..) 00 T H, T = SHA-512 DigestInfo prefix (19 bytes), RFC 8017 A.2.4: 30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40 (vs SHA-384's ... 04 02 02 05 00 04 30 -- the OID's final byte is 03 not 02, and the digest OCTET STRING length is 0x40=64 not 0x30=48) H = SHA-512(message) (64 bytes). PS_LEN = 256-3-19-64 = 170 (RSA-2048) / 512-3-19-64 = 426 (RSA-4096). license_tier: INDEPENDENT_REDERIVE

dependencies 7 imports · 2 importers

nx_syscalls.nx nx_sha512.nx nx_u2048.nx nx_rsa2048_mod_exp.nx nx_rsa2048_mont.nx nx_u4096.nx nx_rsa4096_mod_exp.nx nx_rsa_pkcs1_v1_5_sha512.nx nx_tls12_client.nx nx_tls12_mutant.nx

imports: nx_syscalls.nxnx_sha512.nxnx_u2048.nxnx_rsa2048_mod_exp.nxnx_rsa2048_mont.nxnx_u4096.nxnx_rsa4096_mod_exp.nx

imported by: nx_tls12_client.nxnx_tls12_mutant.nx

structs

none

consts

31const NX_RSA_PKCS1_V15_512_OK: i64 = 1
32const NX_RSA_PKCS1_V15_512_S_OUT_OF_RANGE: i64 = 2
33const NX_RSA_PKCS1_V15_512_BAD_PAD: i64 = 3
34const NX_RSA_PKCS1_V15_512_HASH_MISMATCH: i64 = 4
35const NX_RSA_PKCS1_V15_512_VERDICT_N: i64 = 5
37const NX_RSA512_DI_LEN: i64 = 19
38const NX_RSA512_HASH_LEN: i64 = 64
39const NX_RSA512_PS_2048: i64 = 170
40const NX_RSA512_PS_4096: i64 = 426

functions

42func nx_rsa_pkcs1_v15_512_verdict_is_valid(v: i64) -> i64
49func rsa_pkcs1_sha512_di_byte(i: i64) -> i64
called by 1: _rsa512_check_em
74func _rsa512_check_em(em: *u8, em_len: i64, h: *u8, ps_len: i64) -> i64
100func rsa_pkcs1_v1_5_sha512_verify(msg: *u8, msg_len: i64,
116func rsa_pkcs1_v1_5_sha512_4096_verify(msg: *u8, msg_len: i64,
131func main() -> i64