- bn_modexp_ct: constant-time modexp for the SECRET exponent — squares and multiplies every bit, selects the product with a mask (bn_cmov), so the op sequence is independent of d (the existing bn_modexp branches on the bit, fine only for the public e) - wo_rsa_pss_sha256_sign: EMSA-PSS-ENCODE (RFC 8017 §9.1.1) + modexp with d; caller supplies the salt (fresh in production; fixed makes the KAT deterministic). Private key (n,d) - KAT: deterministic sign vs a python from-spec oracle byte-for-byte (fixed salt), our sign round-trips through our verify, tamper rejected. test_crypto 108, ASan/UBSan clean Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit cf8fdfcc47b2b076b63b9c63bf56411615b0d6f9)
93 lines
4.8 KiB
C
93 lines
4.8 KiB
C
/* Generated: RSA-2048 PSS-SHA256 sign KAT (fixed salt -> deterministic).
|
|
* n/e/d, mhash, salt, and the from-spec expected signature. */
|
|
static const unsigned char rsasig_n[] = {
|
|
0xb7,0x83,0x5a,0x15,0x85,0x7d,0xca,0xe6,0x60,0x90,0xa2,0xc8,
|
|
0x51,0x55,0x5c,0x06,0xac,0x30,0x7d,0xd4,0x23,0x5b,0x79,0x0c,
|
|
0xd1,0x32,0x8b,0x21,0x91,0x7e,0x44,0xb4,0xfa,0x92,0x20,0x4b,
|
|
0xfb,0x68,0xa8,0x95,0x12,0xea,0x14,0xa8,0xfa,0xdd,0x93,0x5f,
|
|
0x66,0x25,0xc7,0xdf,0xbb,0x36,0xe4,0xc2,0xc2,0x85,0x93,0xa8,
|
|
0xdd,0x91,0x57,0x80,0x3d,0x26,0x0d,0x83,0xe7,0x1f,0x24,0xd9,
|
|
0x0e,0xd6,0x15,0x32,0x4a,0x1c,0x59,0xd3,0xf9,0x42,0x65,0xdd,
|
|
0x1d,0x2e,0xf8,0x31,0x92,0xac,0xa3,0xa2,0xa2,0xa9,0x29,0xf3,
|
|
0x8b,0xc7,0x89,0x4f,0x48,0x88,0xac,0x68,0xc9,0xc6,0xa3,0xd9,
|
|
0x2f,0x13,0x63,0x7d,0xab,0xdd,0xa2,0xfd,0x53,0x97,0x6d,0xda,
|
|
0x71,0xcd,0x5a,0xdc,0xf4,0x48,0xa4,0xbc,0xba,0xaf,0xe1,0xf3,
|
|
0x34,0xb7,0xfb,0x19,0x1e,0xa5,0xf1,0x34,0x07,0x72,0xd0,0x5b,
|
|
0x58,0xbe,0xcc,0x11,0x11,0xa7,0x9a,0x27,0x32,0x3c,0x43,0x0e,
|
|
0x68,0xa4,0xe1,0x98,0x4d,0x3c,0xc0,0x12,0x39,0xf0,0xb0,0x32,
|
|
0x85,0x23,0x3e,0xa0,0x0e,0xbb,0xc9,0xd0,0x51,0x6d,0x3a,0x5c,
|
|
0xa9,0xf5,0x58,0xbf,0xb2,0xf7,0xc4,0x27,0x0e,0xee,0xe2,0x56,
|
|
0xbe,0x50,0xa1,0xf9,0xbf,0x44,0xfe,0xaa,0xa0,0x82,0x7a,0x82,
|
|
0x78,0x75,0x11,0xe9,0x96,0xe0,0xd8,0x79,0xfa,0x57,0x84,0xa0,
|
|
0x1b,0x04,0xe8,0x39,0xb3,0x72,0x82,0x23,0xfe,0x64,0xbc,0xd6,
|
|
0xc8,0xae,0x24,0x5e,0x17,0xbc,0xda,0xf8,0x6f,0xb9,0x67,0x2c,
|
|
0x99,0xb2,0x92,0xd2,0xe6,0x9d,0x06,0xf2,0xf2,0x74,0x23,0xef,
|
|
0xe2,0xab,0x88,0x8d,
|
|
};
|
|
|
|
static const unsigned char rsasig_e[] = {
|
|
0x01,0x00,0x01,
|
|
};
|
|
|
|
static const unsigned char rsasig_d[] = {
|
|
0x27,0x8e,0xc1,0xe9,0x67,0xb8,0x20,0xf7,0x9e,0x13,0x2f,0x73,
|
|
0xbc,0xcc,0x88,0xa4,0xcb,0x93,0x3c,0x5c,0x71,0x2e,0xb3,0x9e,
|
|
0x46,0xad,0xfd,0x7d,0xc3,0xee,0x13,0x03,0x6c,0x0b,0xf9,0xb8,
|
|
0x47,0x3e,0x5d,0x30,0x9d,0x3e,0x26,0x2b,0xf2,0xbf,0xb6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,0x60,0xc5,
|
|
};
|
|
|
|
static const unsigned char rsasig_mhash[] = {
|
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,
|
|
0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
|
|
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
|
|
};
|
|
|
|
static const unsigned char rsasig_salt[] = {
|
|
0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,
|
|
0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,
|
|
0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,
|
|
};
|
|
|
|
static const unsigned char rsasig_expect[] = {
|
|
0x06,0xf5,0x56,0x60,0xfa,0x34,0x07,0x13,0x1d,0x65,0x1c,0x00,
|
|
0xc8,0xd1,0xa8,0x91,0x7d,0x1a,0xc8,0x27,0xb1,0x6b,0x4d,0x20,
|
|
0x5b,0x7b,0x7f,0x9d,0x27,0xba,0xa6,0x5b,0x6a,0x26,0x50,0x63,
|
|
0x0d,0x02,0x0c,0xab,0x4c,0x29,0x8e,0x6c,0x61,0x4f,0xdb,0x5b,
|
|
0xcf,0xb5,0xe6,0x2f,0x25,0x10,0x10,0x6a,0x0b,0x65,0x6a,0xf3,
|
|
0xa9,0x62,0x8d,0x56,0x30,0x0d,0x12,0x24,0x9c,0x34,0x43,0xe5,
|
|
0x74,0x35,0x73,0xbd,0x8c,0x22,0x32,0x24,0xe2,0xc1,0x22,0xb8,
|
|
0x4f,0xd3,0x2d,0x0e,0xc4,0xe6,0xc6,0x3e,0xdd,0xfb,0xfd,0xe9,
|
|
0xed,0x6e,0x65,0x0e,0x8f,0xc0,0x30,0x10,0x9a,0x8a,0x8f,0xfd,
|
|
0xec,0x01,0x4a,0x07,0x3b,0xa9,0xcc,0x32,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