nx_rsa_pkcs1_v1_5_sha256.nx
buildroot/runtime/nx_rsa_pkcs1_v1_5_sha256.nx
about
nx_rsa_pkcs1_v1_5_sha256.nx -- RSA-PKCS#1 v1.5 signature verify
with SHA-256 hash, for RSA-2048 keys.
RFC 8017 ยง8.2.2 RSASSA-PKCS1-v1_5-VERIFY (k=256 bytes for RSA-2048):
1. s -> m = s^e mod n (RSA modular exponentiation)
2. Encode message into EM_test:
EM_test = 0x00 || 0x01 || PS (FF*202) || 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).
3. Convert m to 256-byte big-endian EM.
4. Compare EM == EM_test byte-by-byte.
API:
rsa_pkcs1_v1_5_sha256_verify(msg, msg_len, sig_bytes, n_2048, e_i64) -> verdict
Sealed verdict:
NX_RSA_PKCS1_V15_OK valid signature
NX_RSA_PKCS1_V15_S_OUT_OF_RANGE s_int >= n
NX_RSA_PKCS1_V15_BAD_PAD padding (PS / leading bytes / T) mismatch
NX_RSA_PKCS1_V15_HASH_MISMATCH trailing 32 bytes != SHA-256(msg)
Composes:
- sha256_digest
- u2048_load_be / u2048_store_be
- rsa2048_mod_exp
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/ietf/rfc_8017 + nist/fips_180_4
lineage_id: nishi_rsa_pkcs1_v1_5_sha256_q10
dependencies 5 imports · 5 importers
imports: nx_syscalls.nxnx_sha256.nxnx_u2048.nxnx_rsa2048_mod_exp.nxnx_rsa2048_mont.nx
imported by: nx_rsa_pkcs1_v1_5_k.nxnx_rsa_pkcs1_v1_5_sha256_4096.nxnx_rsa_pkcs1_v1_5_sha256_real_test.nxnx_tls12_ske_verify.nxnx_x509_verify_rsa_pkcs1_sha256.nx
structs
| none |
consts
| 44 | const NX_RSA_PKCS1_V15_OK: i64 = 1 |
| 45 | const NX_RSA_PKCS1_V15_S_OUT_OF_RANGE: i64 = 2 |
| 46 | const NX_RSA_PKCS1_V15_BAD_PAD: i64 = 3 |
| 47 | const NX_RSA_PKCS1_V15_HASH_MISMATCH: i64 = 4 |
| 48 | const NX_RSA_PKCS1_V15_VERDICT_N: i64 = 5 |
functions
| 50 | func rsa_pkcs1_v1_5_verdict_is_valid(v: i64) -> i64 |
| 58 | func rsa_pkcs1_sha256_di_byte(i: i64) -> i64 |
| 90 | func rsa_pkcs1_v1_5_sha256_verify(msg: *u8, msg_len: i64, |
| 140 | func main() -> i64 |