code wiki / (root) / nx_rsa_pkcs1_v1_5_sha256_4096_test.nx

nx_rsa_pkcs1_v1_5_sha256_4096_test.nx source

↩ module page · 34 lines · 1504 B

1// nx_rsa_pkcs1_v1_5_sha256_4096_test.nx -- compile + sealed-enum gate. 2// 3// What this test DOES assert: 4// - Module compiles + composes rsa4096_mod_exp + u4096_load_be/store_be 5// - Verdict-validity predicate matches the declared sealed enum 6// - Constants have the expected numeric values 7// 8// What this test DOES NOT assert: 9// - End-to-end RSA-4096 sign/verify round-trip -- requires either 10// real 4096-bit prime generation (substantial side-arc) or a 11// known NIST CAVS RSA-4096 KAT vector (queued). The load-bearing 12// end-to-end exercise is the L11 step 2d re-run with this 13// primitive wired into the cert-chain verifier. 14// 15// expect_exit: 0 16 17import "nx_syscalls.nx" 18import "nx_rsa_pkcs1_v1_5_sha256_4096.nx" 19 20func main() -> i64 { 21 if rsa_pkcs1_v1_5_4096_verdict_is_valid(NX_RSA_PKCS1_V15_4096_OK) != 1 { return 1 } 22 if rsa_pkcs1_v1_5_4096_verdict_is_valid(NX_RSA_PKCS1_V15_4096_S_OUT_OF_RANGE) != 1 { return 2 } 23 if rsa_pkcs1_v1_5_4096_verdict_is_valid(NX_RSA_PKCS1_V15_4096_BAD_PAD) != 1 { return 3 } 24 if rsa_pkcs1_v1_5_4096_verdict_is_valid(NX_RSA_PKCS1_V15_4096_HASH_MISMATCH) != 1 { return 4 } 25 if rsa_pkcs1_v1_5_4096_verdict_is_valid(NX_RSA_PKCS1_V15_4096_VERDICT_N) != 0 { return 5 } 26 if rsa_pkcs1_v1_5_4096_verdict_is_valid(0 - 1) != 0 { return 6 } 27 if NX_RSA_PKCS1_V15_4096_VERDICT_N != 5 { return 7 } 28 29 // PASS 30 let ok: *u8 = sys_mmap(8) 31 ok[0]=80; ok[1]=65; ok[2]=83; ok[3]=83; ok[4]=10 32 sys_write(1, ok, 5) 33 return 0 34}