crypt32/tests: Add a test for CryptSignMessage.
This commit is contained in:
parent
2637bb9de7
commit
665ede7517
|
@ -772,6 +772,406 @@ static void test_hash_message(void)
|
|||
}
|
||||
}
|
||||
|
||||
static const BYTE publicPrivateKeyPair[] = {
|
||||
0x07,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x32,0x00,0x02,0x00,
|
||||
0x00,0x01,0x00,0x01,0x00,0x9b,0xd9,0x60,0xd9,0x5b,0x09,0x50,0x9e,0x09,0x94,
|
||||
0x1e,0x6a,0x06,0x1d,0xdd,0x39,0xc5,0x96,0x17,0xe3,0xb9,0x0c,0x71,0x9c,0xf7,
|
||||
0xc1,0x07,0x7b,0xd7,0x4a,0xaa,0x8a,0x3e,0xcd,0x78,0x3c,0x4c,0x95,0x98,0x28,
|
||||
0x29,0x2d,0xe0,0xfc,0xe6,0x4f,0x95,0xca,0x87,0x92,0xdd,0xa3,0x8d,0xf0,0x39,
|
||||
0xf3,0x1b,0x87,0x64,0x82,0x99,0xc0,0xa9,0xe8,0x87,0x86,0x2e,0x72,0x07,0x07,
|
||||
0x8f,0x45,0x54,0x51,0x2f,0x51,0xd0,0x60,0x97,0x48,0x54,0x0e,0x78,0xb5,0x7e,
|
||||
0x2b,0x9d,0xca,0x81,0xa8,0xa8,0x00,0x57,0x69,0xa6,0xf7,0x4d,0x45,0xe0,0xf7,
|
||||
0xfa,0xd2,0xeb,0xaa,0xb8,0x06,0x34,0xce,0xf0,0x9d,0x2b,0x76,0x8a,0x4f,0x70,
|
||||
0x51,0x90,0x33,0x72,0xcb,0x81,0x85,0x7e,0x35,0x2e,0xfb,0x81,0xf0,0xc7,0x85,
|
||||
0xa5,0x75,0xf9,0x2d,0x00,0x71,0x66,0x36,0xfe,0x22,0xd6,0xc9,0x36,0x61,0x9b,
|
||||
0x64,0x92,0xe8,0x25,0x38,0x35,0xeb,0x0c,0x84,0x83,0x76,0x42,0x90,0xf7,0x73,
|
||||
0x91,0xdc,0x43,0x83,0x07,0x77,0xc9,0x1b,0x3f,0x74,0xc0,0xbe,0x18,0x97,0xd6,
|
||||
0x86,0xe5,0xfa,0x28,0x7c,0xf7,0x8d,0x89,0xb1,0x93,0xac,0x48,0x3c,0xa1,0x02,
|
||||
0xfa,0xc6,0x1c,0xa0,0xb5,0xe8,0x4f,0xd7,0xd1,0x33,0x63,0x8b,0x7e,0xf1,0x94,
|
||||
0x56,0x07,0xbc,0x6e,0x0c,0xbd,0xa0,0x15,0xba,0x99,0x5d,0xb7,0x5e,0x09,0xf2,
|
||||
0x1b,0x46,0x85,0x61,0x91,0x6a,0x78,0x31,0xb5,0xf0,0xba,0x20,0xf5,0x7a,0xb4,
|
||||
0x8e,0xd3,0x50,0x87,0xf8,0xf3,0xe4,0xd9,0xab,0x6f,0x0e,0x59,0x42,0xac,0x7d,
|
||||
0xb1,0x8c,0xea,0x33,0x54,0x08,0x38,0xc9,0xcd,0xac,0x10,0x19,0x4a,0xba,0x89,
|
||||
0xdc,0xb6,0x73,0xef,0xec,0x56,0x93,0xd6,0xf2,0x4b,0xba,0x50,0x2d,0x8f,0x15,
|
||||
0xed,0x8b,0xb5,0x67,0xc8,0xfc,0x51,0x5f };
|
||||
static const BYTE certForSigning[] = {
|
||||
0x30,0x81,0xd0,0x30,0x81,0xbe,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,0x20,0x42,
|
||||
0x68,0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,0x24,0x2f,0x3b,0xad,0x40,0x30,
|
||||
0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x0c,0x31,0x0a,0x30,
|
||||
0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x30,0x20,0x17,0x0d,0x31,0x30,
|
||||
0x30,0x39,0x31,0x34,0x31,0x33,0x31,0x39,0x30,0x39,0x5a,0x18,0x0f,0x33,0x30,
|
||||
0x31,0x30,0x30,0x39,0x31,0x34,0x31,0x33,0x31,0x39,0x30,0x39,0x5a,0x30,0x0c,
|
||||
0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x30,0x5c,0x30,
|
||||
0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,
|
||||
0x4b,0x00,0x30,0x48,0x02,0x41,0x00,0xe8,0xa9,0xc0,0x99,0x82,0x64,0x87,0x1b,
|
||||
0xf3,0x39,0xf0,0x8d,0xa3,0xdd,0x92,0x87,0xca,0x95,0x4f,0xe6,0xfc,0xe0,0x2d,
|
||||
0x29,0x28,0x98,0x95,0x4c,0x3c,0x78,0xcd,0x3e,0x8a,0xaa,0x4a,0xd7,0x7b,0x07,
|
||||
0xc1,0xf7,0x9c,0x71,0x0c,0xb9,0xe3,0x17,0x96,0xc5,0x39,0xdd,0x1d,0x06,0x6a,
|
||||
0x1e,0x94,0x09,0x9e,0x50,0x09,0x5b,0xd9,0x60,0xd9,0x9b,0x02,0x03,0x01,0x00,
|
||||
0x01,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x02,0x00,
|
||||
0xc1 };
|
||||
static const BYTE crl[] = {
|
||||
0x30,0x81,0xc2,0x30,0x7e,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
|
||||
0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x3c,0x31,0x0b,0x30,0x09,0x06,
|
||||
0x03,0x55,0x04,0x06,0x13,0x02,0x52,0x55,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,
|
||||
0x04,0x08,0x13,0x03,0x53,0x50,0x62,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,0x04,
|
||||
0x07,0x13,0x03,0x53,0x50,0x62,0x31,0x11,0x30,0x0f,0x06,0x03,0x55,0x04,0x0a,
|
||||
0x13,0x08,0x45,0x74,0x65,0x72,0x73,0x6f,0x66,0x74,0x17,0x0d,0x31,0x30,0x30,
|
||||
0x36,0x32,0x38,0x31,0x32,0x35,0x31,0x32,0x37,0x5a,0x17,0x0d,0x31,0x30,0x30,
|
||||
0x37,0x32,0x38,0x31,0x32,0x35,0x31,0x32,0x37,0x5a,0xa0,0x0e,0x30,0x0c,0x30,
|
||||
0x0a,0x06,0x03,0x55,0x1d,0x14,0x04,0x03,0x02,0x01,0x00,0x30,0x0d,0x06,0x09,
|
||||
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x31,0x00,0x83,
|
||||
0x35,0x9c,0xf5,0x35,0x5c,0xc1,0x20,0x81,0x80,0x5c,0x35,0x56,0xaf,0xb3,0x27,
|
||||
0x15,0xc6,0xdd,0x24,0xe1,0xff,0xb9,0xf9,0x19,0x21,0xed,0x5e,0x1b,0xff,0x72,
|
||||
0xc3,0x33,0xf6,0x9f,0xcb,0xde,0x84,0x0b,0x12,0x84,0xad,0x48,0x90,0x9d,0xdd,
|
||||
0x89,0xbb };
|
||||
static const BYTE signedHashForEmptyMessage[] = {
|
||||
0x30,0x81,0xbb,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
|
||||
0x81,0xad,0x30,0x81,0xaa,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
|
||||
0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,
|
||||
0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x31,0x81,0x87,0x30,0x81,0x84,0x02,0x01,
|
||||
0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,
|
||||
0x01,0x4e,0x02,0x10,0x20,0x42,0x68,0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,
|
||||
0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
|
||||
0x02,0x05,0x05,0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
|
||||
0x01,0x01,0x05,0x00,0x04,0x40,0xe1,0xee,0xca,0x98,0x16,0x23,0x5a,0x34,0xfd,
|
||||
0x91,0x69,0x97,0x1e,0x16,0xe4,0x57,0x45,0xad,0xc9,0x5d,0x2e,0xda,0x92,0xbf,
|
||||
0xee,0x2f,0xb1,0xaa,0x32,0xfa,0x07,0x4e,0x63,0xfd,0xe1,0x52,0x17,0xd0,0xa4,
|
||||
0x49,0x30,0x54,0x4d,0x12,0xa0,0x6a,0x1c,0x64,0xea,0xc7,0x50,0x49,0xa5,0xca,
|
||||
0xc3,0x71,0xa4,0xf7,0x8c,0x25,0xe4,0x1a,0xca,0x89 };
|
||||
static const BYTE signedEmptyMessage[] = {
|
||||
0x30,0x81,0xbb,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
|
||||
0x81,0xad,0x30,0x81,0xaa,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
|
||||
0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,
|
||||
0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x31,0x81,0x87,0x30,0x81,0x84,0x02,0x01,
|
||||
0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,
|
||||
0x01,0x4e,0x02,0x10,0x20,0x42,0x68,0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,
|
||||
0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
|
||||
0x02,0x05,0x05,0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
|
||||
0x01,0x01,0x05,0x00,0x04,0x40,0xe1,0xee,0xca,0x98,0x16,0x23,0x5a,0x34,0xfd,
|
||||
0x91,0x69,0x97,0x1e,0x16,0xe4,0x57,0x45,0xad,0xc9,0x5d,0x2e,0xda,0x92,0xbf,
|
||||
0xee,0x2f,0xb1,0xaa,0x32,0xfa,0x07,0x4e,0x63,0xfd,0xe1,0x52,0x17,0xd0,0xa4,
|
||||
0x49,0x30,0x54,0x4d,0x12,0xa0,0x6a,0x1c,0x64,0xea,0xc7,0x50,0x49,0xa5,0xca,
|
||||
0xc3,0x71,0xa4,0xf7,0x8c,0x25,0xe4,0x1a,0xca,0x89 };
|
||||
static const BYTE signedHash[] = {
|
||||
0x30,0x81,0xbb,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
|
||||
0x81,0xad,0x30,0x81,0xaa,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
|
||||
0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0b,0x06,0x09,0x2a,0x86,
|
||||
0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0x31,0x81,0x87,0x30,0x81,0x84,0x02,0x01,
|
||||
0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,
|
||||
0x01,0x4e,0x02,0x10,0x20,0x42,0x68,0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,
|
||||
0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,
|
||||
0x02,0x05,0x05,0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
|
||||
0x01,0x01,0x05,0x00,0x04,0x40,0x1e,0x04,0xa4,0xe3,0x90,0x54,0xed,0xcb,0x94,
|
||||
0xa2,0xbe,0x81,0x73,0x7e,0x05,0xf2,0x82,0xd3,0x3a,0x26,0x96,0x7a,0x53,0xcd,
|
||||
0x05,0xc3,0x09,0x69,0x3d,0x12,0x6c,0xb1,0xb0,0xab,0x0e,0xa1,0xec,0x1b,0xa1,
|
||||
0xff,0x01,0x9c,0x49,0x9f,0x4b,0x69,0x59,0x74,0x20,0x9f,0xb0,0x19,0x95,0xe7,
|
||||
0xed,0x1e,0x84,0xeb,0xe2,0x53,0x2c,0xa6,0x43,0xdf };
|
||||
static const BYTE signedHashWithCert[] = {
|
||||
0x30,0x82,0x01,0x93,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,
|
||||
0xa0,0x82,0x01,0x84,0x30,0x82,0x01,0x80,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,
|
||||
0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0b,0x06,
|
||||
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x81,0xd3,0x30,0x81,
|
||||
0xd0,0x30,0x81,0xbe,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,0x20,0x42,0x68,0x69,
|
||||
0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,0x24,0x2f,0x3b,0xad,0x40,0x30,0x09,0x06,
|
||||
0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x30,0x0c,0x31,0x0a,0x30,0x08,0x06,
|
||||
0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x30,0x20,0x17,0x0d,0x31,0x30,0x30,0x39,
|
||||
0x31,0x34,0x31,0x33,0x31,0x39,0x30,0x39,0x5a,0x18,0x0f,0x33,0x30,0x31,0x30,
|
||||
0x30,0x39,0x31,0x34,0x31,0x33,0x31,0x39,0x30,0x39,0x5a,0x30,0x0c,0x31,0x0a,
|
||||
0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x30,0x5c,0x30,0x0d,0x06,
|
||||
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x4b,0x00,
|
||||
0x30,0x48,0x02,0x41,0x00,0xe8,0xa9,0xc0,0x99,0x82,0x64,0x87,0x1b,0xf3,0x39,
|
||||
0xf0,0x8d,0xa3,0xdd,0x92,0x87,0xca,0x95,0x4f,0xe6,0xfc,0xe0,0x2d,0x29,0x28,
|
||||
0x98,0x95,0x4c,0x3c,0x78,0xcd,0x3e,0x8a,0xaa,0x4a,0xd7,0x7b,0x07,0xc1,0xf7,
|
||||
0x9c,0x71,0x0c,0xb9,0xe3,0x17,0x96,0xc5,0x39,0xdd,0x1d,0x06,0x6a,0x1e,0x94,
|
||||
0x09,0x9e,0x50,0x09,0x5b,0xd9,0x60,0xd9,0x9b,0x02,0x03,0x01,0x00,0x01,0x30,
|
||||
0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1d,0x05,0x00,0x03,0x02,0x00,0xc1,0x31,
|
||||
0x81,0x87,0x30,0x81,0x84,0x02,0x01,0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,0x30,
|
||||
0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x02,0x10,0x20,0x42,0x68,0x69,
|
||||
0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,0x06,
|
||||
0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0d,0x06,0x09,
|
||||
0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x04,0x40,0x1e,0x04,
|
||||
0xa4,0xe3,0x90,0x54,0xed,0xcb,0x94,0xa2,0xbe,0x81,0x73,0x7e,0x05,0xf2,0x82,
|
||||
0xd3,0x3a,0x26,0x96,0x7a,0x53,0xcd,0x05,0xc3,0x09,0x69,0x3d,0x12,0x6c,0xb1,
|
||||
0xb0,0xab,0x0e,0xa1,0xec,0x1b,0xa1,0xff,0x01,0x9c,0x49,0x9f,0x4b,0x69,0x59,
|
||||
0x74,0x20,0x9f,0xb0,0x19,0x95,0xe7,0xed,0x1e,0x84,0xeb,0xe2,0x53,0x2c,0xa6,
|
||||
0x43,0xdf };
|
||||
static const BYTE signedHashWithCRL[] = {
|
||||
0x30,0x82,0x01,0x85,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,
|
||||
0xa0,0x82,0x01,0x76,0x30,0x82,0x01,0x72,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,
|
||||
0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0b,0x06,
|
||||
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa1,0x81,0xc5,0x30,0x81,
|
||||
0xc2,0x30,0x7e,0x02,0x01,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
|
||||
0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x3c,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,
|
||||
0x04,0x06,0x13,0x02,0x52,0x55,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,0x04,0x08,
|
||||
0x13,0x03,0x53,0x50,0x62,0x31,0x0c,0x30,0x0a,0x06,0x03,0x55,0x04,0x07,0x13,
|
||||
0x03,0x53,0x50,0x62,0x31,0x11,0x30,0x0f,0x06,0x03,0x55,0x04,0x0a,0x13,0x08,
|
||||
0x45,0x74,0x65,0x72,0x73,0x6f,0x66,0x74,0x17,0x0d,0x31,0x30,0x30,0x36,0x32,
|
||||
0x38,0x31,0x32,0x35,0x31,0x32,0x37,0x5a,0x17,0x0d,0x31,0x30,0x30,0x37,0x32,
|
||||
0x38,0x31,0x32,0x35,0x31,0x32,0x37,0x5a,0xa0,0x0e,0x30,0x0c,0x30,0x0a,0x06,
|
||||
0x03,0x55,0x1d,0x14,0x04,0x03,0x02,0x01,0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,
|
||||
0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x31,0x00,0x83,0x35,0x9c,
|
||||
0xf5,0x35,0x5c,0xc1,0x20,0x81,0x80,0x5c,0x35,0x56,0xaf,0xb3,0x27,0x15,0xc6,
|
||||
0xdd,0x24,0xe1,0xff,0xb9,0xf9,0x19,0x21,0xed,0x5e,0x1b,0xff,0x72,0xc3,0x33,
|
||||
0xf6,0x9f,0xcb,0xde,0x84,0x0b,0x12,0x84,0xad,0x48,0x90,0x9d,0xdd,0x89,0xbb,
|
||||
0x31,0x81,0x87,0x30,0x81,0x84,0x02,0x01,0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,
|
||||
0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x02,0x10,0x20,0x42,0x68,
|
||||
0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,
|
||||
0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0d,0x06,
|
||||
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x04,0x40,0x1e,
|
||||
0x04,0xa4,0xe3,0x90,0x54,0xed,0xcb,0x94,0xa2,0xbe,0x81,0x73,0x7e,0x05,0xf2,
|
||||
0x82,0xd3,0x3a,0x26,0x96,0x7a,0x53,0xcd,0x05,0xc3,0x09,0x69,0x3d,0x12,0x6c,
|
||||
0xb1,0xb0,0xab,0x0e,0xa1,0xec,0x1b,0xa1,0xff,0x01,0x9c,0x49,0x9f,0x4b,0x69,
|
||||
0x59,0x74,0x20,0x9f,0xb0,0x19,0x95,0xe7,0xed,0x1e,0x84,0xeb,0xe2,0x53,0x2c,
|
||||
0xa6,0x43,0xdf };
|
||||
static const BYTE signedData[] = {
|
||||
0x30,0x81,0xc3,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x07,0x02,0xa0,
|
||||
0x81,0xb5,0x30,0x81,0xb2,0x02,0x01,0x01,0x31,0x0e,0x30,0x0c,0x06,0x08,0x2a,
|
||||
0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x13,0x06,0x09,0x2a,0x86,
|
||||
0x48,0x86,0xf7,0x0d,0x01,0x07,0x01,0xa0,0x06,0x04,0x04,0x01,0x02,0x03,0x04,
|
||||
0x31,0x81,0x87,0x30,0x81,0x84,0x02,0x01,0x01,0x30,0x20,0x30,0x0c,0x31,0x0a,
|
||||
0x30,0x08,0x06,0x03,0x55,0x04,0x03,0x13,0x01,0x4e,0x02,0x10,0x20,0x42,0x68,
|
||||
0x69,0xe9,0xea,0x61,0x83,0x11,0xdf,0xc0,0x24,0x2f,0x3b,0xad,0x40,0x30,0x0c,
|
||||
0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x30,0x0d,0x06,
|
||||
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x04,0x40,0xe4,
|
||||
0x69,0xf5,0x62,0xfb,0x3a,0x7d,0x1c,0x7b,0x8b,0xcc,0xfc,0x6e,0x8e,0x91,0x85,
|
||||
0xcf,0x3c,0xb8,0xfd,0x8a,0xac,0x81,0x96,0xa0,0x42,0xac,0x88,0xc4,0x48,0xe8,
|
||||
0x43,0x64,0xd1,0x38,0xd2,0x6c,0xc4,0xd4,0x9b,0x9a,0xd4,0x33,0x02,0xef,0x88,
|
||||
0xef,0x98,0x2d,0xac,0xad,0xc1,0x93,0x60,0xc4,0x3a,0xdc,0xa7,0xd6,0x97,0x70,
|
||||
0x01,0xc1,0x84 };
|
||||
|
||||
static void test_sign_message(void)
|
||||
{
|
||||
BOOL ret;
|
||||
CRYPT_SIGN_MESSAGE_PARA para;
|
||||
static char oid_rsa_md5[] = szOID_RSA_MD5;
|
||||
static const BYTE blob1[] = { 0x01, 0x02, 0x03, 0x04 };
|
||||
static const BYTE blob2[] = { 0x11, 0x12, 0x13, 0x14 };
|
||||
const BYTE *toSign[] = { blob1, blob2 };
|
||||
DWORD signSize[] = { sizeof(blob1), sizeof(blob2) };
|
||||
LPBYTE signedBlob;
|
||||
DWORD signedBlobSize;
|
||||
PCCRL_CONTEXT crlContext;
|
||||
CERT_KEY_CONTEXT keyContext;
|
||||
HCRYPTPROV hCryptProv = 0;
|
||||
HCRYPTKEY hKey = 0;
|
||||
|
||||
memset(¶, 0, sizeof(para));
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
|
||||
todo_wine
|
||||
ok(!ret &&
|
||||
(GetLastError() == E_INVALIDARG ||
|
||||
GetLastError() == ERROR_ARITHMETIC_OVERFLOW), /* Win7 */
|
||||
"expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08x\n",
|
||||
GetLastError());
|
||||
para.cbSize = sizeof(para);
|
||||
para.dwMsgEncodingType = X509_ASN_ENCODING;
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 255;
|
||||
ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
|
||||
todo_wine
|
||||
ok(!ret && GetLastError() == E_INVALIDARG,
|
||||
"expected E_INVALIDARG, got %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(!signedBlobSize, "unexpected size %d\n", signedBlobSize);
|
||||
para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize, "bad size\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT);
|
||||
ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptImportKey(hCryptProv, publicPrivateKeyPair,
|
||||
sizeof(publicPrivateKeyPair), 0, 0, &hKey);
|
||||
if (!ret && GetLastError() == NTE_PERM) /* Win9x */
|
||||
{
|
||||
skip("Failed to import a key\n");
|
||||
if (hCryptProv)
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return;
|
||||
}
|
||||
ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
|
||||
|
||||
para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
|
||||
SetLastError(0xdeadbeef);
|
||||
para.pSigningCert = CertCreateCertificateContext(X509_ASN_ENCODING |
|
||||
PKCS_7_ASN_ENCODING, certForSigning, sizeof(certForSigning));
|
||||
ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08x\n",
|
||||
GetLastError());
|
||||
para.HashAlgorithm.pszObjId = oid_rsa_md5;
|
||||
|
||||
memset(&keyContext, 0, sizeof(keyContext));
|
||||
keyContext.cbSize = sizeof(keyContext);
|
||||
keyContext.hCryptProv = hCryptProv;
|
||||
keyContext.dwKeySpec = AT_SIGNATURE;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CertSetCertificateContextProperty(para.pSigningCert,
|
||||
CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext);
|
||||
ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, TRUE, 0, NULL, NULL, NULL, &signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, TRUE, 0, NULL, NULL, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedHashForEmptyMessage),
|
||||
"unexpected size %d\n", signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedHashForEmptyMessage, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, FALSE, 0, NULL, NULL, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %d\n",
|
||||
signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedEmptyMessage, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedHash),
|
||||
"unexpected size of signed blob %d\n", signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedHash, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
para.cMsgCert = 1;
|
||||
para.rgpMsgCert = ¶.pSigningCert;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedHashWithCert),
|
||||
"unexpected size of signed blob %d\n", signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedHashWithCert, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
para.cMsgCert = 0;
|
||||
para.rgpMsgCert = NULL;
|
||||
para.cMsgCrl = 1;
|
||||
SetLastError(0xdeadbeef);
|
||||
crlContext = CertCreateCRLContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
|
||||
crl, sizeof(crl));
|
||||
ok(crlContext != NULL, "CertCreateCRLContext failed: %08x\n",
|
||||
GetLastError());
|
||||
para.rgpMsgCrl = &crlContext;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, NULL,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, TRUE, 2, toSign, signSize, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedHashWithCRL),
|
||||
"unexpected size of signed blob %d\n", signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedHashWithCRL, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
CertFreeCRLContext(crlContext);
|
||||
para.cMsgCrl = 0;
|
||||
para.rgpMsgCrl = NULL;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
signedBlobSize = 0;
|
||||
ret = CryptSignMessage(¶, FALSE, 1, toSign, signSize, NULL,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
signedBlob = CryptMemAlloc(signedBlobSize);
|
||||
if (signedBlob)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CryptSignMessage(¶, FALSE, 1, toSign, signSize, signedBlob,
|
||||
&signedBlobSize);
|
||||
todo_wine
|
||||
ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
|
||||
todo_wine
|
||||
ok(signedBlobSize == sizeof(signedData),
|
||||
"unexpected size of signed blob %d\n", signedBlobSize);
|
||||
ok(!memcmp(signedBlob, signedData, signedBlobSize),
|
||||
"unexpected value\n");
|
||||
CryptMemFree(signedBlob);
|
||||
}
|
||||
|
||||
if (para.pSigningCert)
|
||||
CertFreeCertificateContext(para.pSigningCert);
|
||||
if (hKey)
|
||||
CryptDestroyKey(hKey);
|
||||
if (hCryptProv)
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
}
|
||||
|
||||
START_TEST(message)
|
||||
{
|
||||
test_msg_get_signer_count();
|
||||
|
@ -780,4 +1180,5 @@ START_TEST(message)
|
|||
test_verify_detached_message_signature();
|
||||
test_verify_message_signature();
|
||||
test_hash_message();
|
||||
test_sign_message();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue