mirror of
https://github.com/reactos/wine.git
synced 2024-11-26 21:20:25 +00:00
rsaenh: Test exporting an RSA private key with the most significant bit set.
This commit is contained in:
parent
ab1f58864e
commit
812fdca9d6
@ -1632,10 +1632,10 @@ static void test_rsa_encrypt(void)
|
||||
static void test_import_export(void)
|
||||
{
|
||||
DWORD dwLen, dwDataLen, dwVal;
|
||||
HCRYPTKEY hPublicKey;
|
||||
HCRYPTKEY hPublicKey, hPrivKey;
|
||||
BOOL result;
|
||||
ALG_ID algID;
|
||||
BYTE emptyKey[2048];
|
||||
BYTE emptyKey[2048], *exported_key;
|
||||
static BYTE abPlainPublicKey[84] = {
|
||||
0x06, 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00,
|
||||
0x52, 0x53, 0x41, 0x31, 0x00, 0x02, 0x00, 0x00,
|
||||
@ -1649,6 +1649,160 @@ static void test_import_export(void)
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
0x11, 0x11, 0x11, 0x11
|
||||
};
|
||||
static BYTE priv_key_with_high_bit[] = {
|
||||
0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
|
||||
0x52, 0x53, 0x41, 0x32, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x01, 0x00, 0xd5, 0xa2, 0x0d, 0x66,
|
||||
0xfe, 0x65, 0xb5, 0xf1, 0xc9, 0x6b, 0xf5, 0x58,
|
||||
0x04, 0x38, 0x2d, 0xf4, 0xa3, 0x5a, 0xda, 0x9e,
|
||||
0x95, 0x81, 0x85, 0x3d, 0x01, 0x07, 0xb2, 0x03,
|
||||
0x77, 0x70, 0x79, 0x6e, 0x6c, 0x26, 0x42, 0xa4,
|
||||
0x12, 0xfd, 0xaa, 0x29, 0x83, 0x04, 0xce, 0x91,
|
||||
0x90, 0x39, 0x5e, 0x49, 0x56, 0xfd, 0x0a, 0xe5,
|
||||
0xb1, 0xea, 0x3b, 0xb2, 0x70, 0xb0, 0x20, 0xc1,
|
||||
0x1f, 0x22, 0x07, 0x3e, 0x4d, 0xc0, 0x73, 0xfd,
|
||||
0x92, 0x8f, 0x87, 0xd8, 0xd1, 0xd1, 0x28, 0xd8,
|
||||
0x19, 0xd1, 0x93, 0x83, 0xe0, 0xb8, 0x9f, 0x53,
|
||||
0xf4, 0x6a, 0x7c, 0xcb, 0x10, 0x53, 0xd0, 0x37,
|
||||
0x02, 0xb4, 0xa5, 0xf7, 0xa2, 0x28, 0x6e, 0x26,
|
||||
0xef, 0x5c, 0x14, 0x01, 0x40, 0x1e, 0xa3, 0xe1,
|
||||
0xda, 0x76, 0xd0, 0x12, 0x84, 0xb7, 0x48, 0x7d,
|
||||
0xc8, 0x67, 0x5c, 0xb2, 0xd5, 0x2e, 0xaf, 0x8e,
|
||||
0x7d, 0x32, 0x59, 0x92, 0x01, 0xd6, 0x5b, 0x68,
|
||||
0x28, 0x9b, 0xb1, 0x6c, 0x69, 0xeb, 0x61, 0x5b,
|
||||
0x4b, 0x13, 0xe2, 0xbd, 0x7d, 0xbe, 0xce, 0xe8,
|
||||
0x41, 0x54, 0xca, 0xa8, 0xdd, 0xc7, 0xfe, 0x8b,
|
||||
0xdf, 0xf6, 0x55, 0x6c, 0x50, 0x11, 0xc8, 0x15,
|
||||
0x13, 0x42, 0x59, 0x9f, 0xbb, 0xea, 0x73, 0x78,
|
||||
0x7b, 0x22, 0x8d, 0x96, 0x62, 0xe5, 0xda, 0xa2,
|
||||
0x85, 0x5c, 0x20, 0x74, 0x9f, 0x1c, 0x12, 0xf2,
|
||||
0x48, 0x06, 0x1a, 0xc6, 0xd5, 0x94, 0xec, 0x31,
|
||||
0x6b, 0xb6, 0x7b, 0x54, 0x61, 0x77, 0xec, 0x7c,
|
||||
0x6f, 0xb7, 0x55, 0x3d, 0x6b, 0x98, 0x05, 0xd7,
|
||||
0x8a, 0x73, 0x25, 0xf2, 0x8f, 0xe4, 0xb8, 0x8d,
|
||||
0x27, 0x18, 0x0d, 0x05, 0xba, 0x23, 0x54, 0x37,
|
||||
0x10, 0xf0, 0x1c, 0x41, 0xa6, 0xae, 0x4c, 0x2a,
|
||||
0x6a, 0x2f, 0x7f, 0x68, 0x43, 0x86, 0xe7, 0x9c,
|
||||
0xfd, 0x9e, 0xf1, 0xfe, 0x84, 0xe3, 0xb6, 0x99,
|
||||
0x51, 0xfe, 0x1e, 0xbd, 0x01, 0xc6, 0x10, 0xef,
|
||||
0x88, 0xa4, 0xd8, 0x53, 0x14, 0x88, 0x15, 0xc9,
|
||||
0xe5, 0x86, 0xe2, 0x8d, 0x85, 0x2e, 0x0d, 0xec,
|
||||
0x15, 0xa7, 0x48, 0xfa, 0x18, 0xfb, 0x01, 0x8d,
|
||||
0x2b, 0x90, 0x70, 0x7f, 0x78, 0xb1, 0x33, 0x7e,
|
||||
0xfe, 0x82, 0x40, 0x5f, 0x4a, 0x97, 0xc2, 0x42,
|
||||
0x22, 0xd5, 0x5f, 0xbc, 0xbd, 0xab, 0x26, 0x98,
|
||||
0xcd, 0xb5, 0xdf, 0x7e, 0xa0, 0x68, 0xa7, 0x12,
|
||||
0x9e, 0xa5, 0xa2, 0x90, 0x85, 0xc5, 0xca, 0x73,
|
||||
0x4a, 0x59, 0x8a, 0xec, 0xcf, 0xdd, 0x65, 0x5d,
|
||||
0xc1, 0xaa, 0x86, 0x53, 0xd5, 0xde, 0xbb, 0x23,
|
||||
0x24, 0xb8, 0x9b, 0x74, 0x03, 0x20, 0xb4, 0xf0,
|
||||
0xe4, 0xdd, 0xd2, 0x03, 0xfd, 0x67, 0x55, 0x19,
|
||||
0x28, 0x1d, 0xc1, 0xb8, 0xa5, 0x89, 0x0e, 0xc0,
|
||||
0x80, 0x9d, 0xdd, 0xda, 0x9d, 0x30, 0x5c, 0xc8,
|
||||
0xbb, 0xfe, 0x8f, 0xce, 0xd5, 0xf6, 0xdf, 0xfa,
|
||||
0x14, 0xaf, 0xe4, 0xba, 0xb0, 0x84, 0x45, 0xd8,
|
||||
0x67, 0xa7, 0xd0, 0xce, 0x89, 0x2a, 0x30, 0x8c,
|
||||
0xfa, 0xe9, 0x65, 0xa4, 0x21, 0x2d, 0x6b, 0xa2,
|
||||
0x9b, 0x8f, 0x92, 0xbd, 0x3a, 0x10, 0x71, 0x12,
|
||||
0xc2, 0x02, 0x3d, 0xd5, 0x83, 0x1d, 0xfa, 0x42,
|
||||
0xb7, 0x48, 0x1b, 0x31, 0xe3, 0x82, 0x90, 0x2d,
|
||||
0x91, 0x59, 0xf9, 0x38, 0x52, 0xe5, 0xdb, 0xc1,
|
||||
0x4d, 0x3a, 0xe6, 0x9b, 0x6a, 0xbb, 0xea, 0xa4,
|
||||
0x8d, 0x5e, 0xc4, 0x00, 0x01, 0xb8, 0xec, 0x91,
|
||||
0xc1, 0xdb, 0x63, 0xbd, 0x57, 0xb6, 0x26, 0x15,
|
||||
0xb6, 0x3e, 0xa2, 0xdf, 0x62, 0x8d, 0xa8, 0xbe,
|
||||
0xe1, 0xf1, 0x39, 0xbd, 0x18, 0xd2, 0x6f, 0xd7,
|
||||
0xda, 0xdc, 0x71, 0x30, 0xf1, 0x21, 0x71, 0xa4,
|
||||
0x08, 0x43, 0x46, 0xdf, 0x50, 0xbd, 0x3c, 0x60,
|
||||
0x5b, 0x63, 0x35, 0xe3, 0x37, 0x5b, 0x25, 0x17,
|
||||
0x54, 0x5e, 0x68, 0x60, 0xb6, 0x49, 0xef, 0x6e,
|
||||
0x09, 0xef, 0xda, 0x90, 0x3e, 0xd4, 0x09, 0x33,
|
||||
0x36, 0x57, 0x9a, 0x14, 0xbd, 0xf7, 0xb1, 0x98,
|
||||
0x30, 0x42, 0x03, 0x84, 0x61, 0xeb, 0x8e, 0x50,
|
||||
0xdc, 0x6a, 0x93, 0x1b, 0x32, 0x51, 0xf9, 0xc6,
|
||||
0xc2, 0x19, 0xb3, 0x5d, 0xe2, 0xf8, 0xc5, 0x8f,
|
||||
0x68, 0xaa, 0x1d, 0xdb, 0xd3, 0x7f, 0x8d, 0x98,
|
||||
0x9c, 0x16, 0x8c, 0xc3, 0xcd, 0xd9, 0xdb, 0x08,
|
||||
0xe6, 0x36, 0x60, 0xb6, 0x36, 0xdc, 0x1d, 0x59,
|
||||
0xb6, 0x5f, 0x01, 0x5e
|
||||
};
|
||||
static const BYTE expected_exported_priv_key[] = {
|
||||
0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
|
||||
0x52, 0x53, 0x41, 0x32, 0x00, 0x04, 0x00, 0x00,
|
||||
0x01, 0x00, 0x01, 0x00, 0xd5, 0xa2, 0x0d, 0x66,
|
||||
0xfe, 0x65, 0xb5, 0xf1, 0xc9, 0x6b, 0xf5, 0x58,
|
||||
0x04, 0x38, 0x2d, 0xf4, 0xa3, 0x5a, 0xda, 0x9e,
|
||||
0x95, 0x81, 0x85, 0x3d, 0x01, 0x07, 0xb2, 0x03,
|
||||
0x77, 0x70, 0x79, 0x6e, 0x6c, 0x26, 0x42, 0xa4,
|
||||
0x12, 0xfd, 0xaa, 0x29, 0x83, 0x04, 0xce, 0x91,
|
||||
0x90, 0x39, 0x5e, 0x49, 0x56, 0xfd, 0x0a, 0xe5,
|
||||
0xb1, 0xea, 0x3b, 0xb2, 0x70, 0xb0, 0x20, 0xc1,
|
||||
0x1f, 0x22, 0x07, 0x3e, 0x4d, 0xc0, 0x73, 0xfd,
|
||||
0x92, 0x8f, 0x87, 0xd8, 0xd1, 0xd1, 0x28, 0xd8,
|
||||
0x19, 0xd1, 0x93, 0x83, 0xe0, 0xb8, 0x9f, 0x53,
|
||||
0xf4, 0x6a, 0x7c, 0xcb, 0x10, 0x53, 0xd0, 0x37,
|
||||
0x02, 0xb4, 0xa5, 0xf7, 0xa2, 0x28, 0x6e, 0x26,
|
||||
0xef, 0x5c, 0x14, 0x01, 0x40, 0x1e, 0xa3, 0xe1,
|
||||
0xda, 0x76, 0xd0, 0x12, 0x84, 0xb7, 0x48, 0x7d,
|
||||
0xc8, 0x67, 0x5c, 0xb2, 0xd5, 0x2e, 0xaf, 0x8e,
|
||||
0x7d, 0x32, 0x59, 0x92, 0x01, 0xd6, 0x5b, 0x68,
|
||||
0x28, 0x9b, 0xb1, 0x6c, 0x69, 0xeb, 0x61, 0x5b,
|
||||
0x4b, 0x13, 0xe2, 0xbd, 0x7d, 0xbe, 0xce, 0xe8,
|
||||
0x41, 0x54, 0xca, 0xa8, 0xdd, 0xc7, 0xfe, 0x8b,
|
||||
0xdf, 0xf6, 0x55, 0x6c, 0x50, 0x11, 0xc8, 0x15,
|
||||
0x13, 0x42, 0x59, 0x9f, 0xbb, 0xea, 0x73, 0x78,
|
||||
0x7b, 0x22, 0x8d, 0x96, 0x62, 0xe5, 0xda, 0xa2,
|
||||
0x85, 0x5c, 0x20, 0x74, 0x9f, 0x1c, 0x12, 0xf2,
|
||||
0x48, 0x06, 0x1a, 0xc6, 0xd5, 0x94, 0xec, 0x31,
|
||||
0x6b, 0xb6, 0x7b, 0x54, 0x61, 0x77, 0xec, 0x7c,
|
||||
0x6f, 0xb7, 0x55, 0x3d, 0x6b, 0x98, 0x05, 0xd7,
|
||||
0x8a, 0x73, 0x25, 0xf2, 0x8f, 0xe4, 0xb8, 0x8d,
|
||||
0x27, 0x18, 0x0d, 0x05, 0xba, 0x23, 0x54, 0x37,
|
||||
0x10, 0xf0, 0x1c, 0x41, 0xa6, 0xae, 0x4c, 0x2a,
|
||||
0x6a, 0x2f, 0x7f, 0x68, 0x43, 0x86, 0xe7, 0x9c,
|
||||
0xfd, 0x9e, 0xf1, 0xfe, 0x84, 0xe3, 0xb6, 0x99,
|
||||
0x51, 0xfe, 0x1e, 0xbd, 0x01, 0xc6, 0x10, 0xef,
|
||||
0x88, 0xa4, 0xd8, 0x53, 0x14, 0x88, 0x15, 0xc9,
|
||||
0xe5, 0x86, 0xe2, 0x8d, 0x85, 0x2e, 0x0d, 0xec,
|
||||
0x15, 0xa7, 0x48, 0xfa, 0x18, 0xfb, 0x01, 0x8d,
|
||||
0x2b, 0x90, 0x70, 0x7f, 0x78, 0xb1, 0x33, 0x7e,
|
||||
0xfe, 0x82, 0x40, 0x5f, 0x4a, 0x97, 0xc2, 0x42,
|
||||
0x22, 0xd5, 0x5f, 0xbc, 0xbd, 0xab, 0x26, 0x98,
|
||||
0xcd, 0xb5, 0xdf, 0x7e, 0xa0, 0x68, 0xa7, 0x12,
|
||||
0x9e, 0xa5, 0xa2, 0x90, 0x85, 0xc5, 0xca, 0x73,
|
||||
0x4a, 0x59, 0x8a, 0xec, 0xcf, 0xdd, 0x65, 0x5d,
|
||||
0xc1, 0xaa, 0x86, 0x53, 0xd5, 0xde, 0xbb, 0x23,
|
||||
0x24, 0xb8, 0x9b, 0x74, 0x03, 0x20, 0xb4, 0xf0,
|
||||
0xe4, 0xdd, 0xd2, 0x03, 0xfd, 0x67, 0x55, 0x19,
|
||||
0x28, 0x1d, 0xc1, 0xb8, 0xa5, 0x89, 0x0e, 0xc0,
|
||||
0x80, 0x9d, 0xdd, 0xda, 0x9d, 0x30, 0x5c, 0xc8,
|
||||
0xbb, 0xfe, 0x8f, 0xce, 0xd5, 0xf6, 0xdf, 0xfa,
|
||||
0x14, 0xaf, 0xe4, 0xba, 0xb0, 0x84, 0x45, 0xd8,
|
||||
0x67, 0xa7, 0xd0, 0xce, 0x89, 0x2a, 0x30, 0x8c,
|
||||
0xfa, 0xe9, 0x65, 0xa4, 0x21, 0x2d, 0x6b, 0xa2,
|
||||
0x9b, 0x8f, 0x92, 0xbd, 0x3a, 0x10, 0x71, 0x12,
|
||||
0xc2, 0x02, 0x3d, 0xd5, 0x83, 0x1d, 0xfa, 0x42,
|
||||
0xb7, 0x48, 0x1b, 0x31, 0xe3, 0x82, 0x90, 0x2d,
|
||||
0x91, 0x59, 0xf9, 0x38, 0x52, 0xe5, 0xdb, 0xc1,
|
||||
0x4d, 0x3a, 0xe6, 0x9b, 0x6a, 0xbb, 0xea, 0xa4,
|
||||
0x8d, 0x5e, 0xc4, 0x00, 0x01, 0xb8, 0xec, 0x91,
|
||||
0xc1, 0xdb, 0x63, 0xbd, 0x57, 0xb6, 0x26, 0x15,
|
||||
0xb6, 0x3e, 0xa2, 0xdf, 0x62, 0x8d, 0xa8, 0xbe,
|
||||
0xe1, 0xf1, 0x39, 0xbd, 0x18, 0xd2, 0x6f, 0xd7,
|
||||
0xda, 0xdc, 0x71, 0x30, 0xf1, 0x21, 0x71, 0xa4,
|
||||
0x08, 0x43, 0x46, 0xdf, 0x50, 0xbd, 0x3c, 0x60,
|
||||
0x5b, 0x63, 0x35, 0xe3, 0x37, 0x5b, 0x25, 0x17,
|
||||
0x54, 0x5e, 0x68, 0x60, 0xb6, 0x49, 0xef, 0x6e,
|
||||
0x09, 0xef, 0xda, 0x90, 0x3e, 0xd4, 0x09, 0x33,
|
||||
0x36, 0x57, 0x9a, 0x14, 0xbd, 0xf7, 0xb1, 0x98,
|
||||
0x30, 0x42, 0x03, 0x84, 0x61, 0xeb, 0x8e, 0x50,
|
||||
0xdc, 0x6a, 0x93, 0x1b, 0x32, 0x51, 0xf9, 0xc6,
|
||||
0xc2, 0x19, 0xb3, 0x5d, 0xe2, 0xf8, 0xc5, 0x8f,
|
||||
0x68, 0xaa, 0x1d, 0xdb, 0xd3, 0x7f, 0x8d, 0x98,
|
||||
0x9c, 0x16, 0x8c, 0xc3, 0xcd, 0xd9, 0xdb, 0x08,
|
||||
0xe6, 0x36, 0x60, 0xb6, 0x36, 0xdc, 0x1d, 0x59,
|
||||
0xb6, 0x5f, 0x01, 0x5e
|
||||
};
|
||||
|
||||
dwLen=84;
|
||||
result = CryptImportKey(hProv, abPlainPublicKey, dwLen, 0, 0, &hPublicKey);
|
||||
@ -1674,6 +1828,27 @@ static void test_import_export(void)
|
||||
ok(!memcmp(emptyKey, abPlainPublicKey, dwLen), "exported key is different from the imported key\n");
|
||||
|
||||
CryptDestroyKey(hPublicKey);
|
||||
|
||||
result = CryptImportKey(hProv, priv_key_with_high_bit,
|
||||
sizeof(priv_key_with_high_bit), 0, CRYPT_EXPORTABLE, &hPrivKey);
|
||||
ok(result, "CryptImportKey failed: %08x\n", GetLastError());
|
||||
|
||||
result = CryptExportKey(hPrivKey, 0, PRIVATEKEYBLOB, 0, NULL, &dwDataLen);
|
||||
ok(result, "CryptExportKey failed: %08x\n", GetLastError());
|
||||
exported_key = HeapAlloc(GetProcessHeap(), 0, dwDataLen);
|
||||
result = CryptExportKey(hPrivKey, 0, PRIVATEKEYBLOB, 0, exported_key,
|
||||
&dwDataLen);
|
||||
ok(result, "CryptExportKey failed: %08x\n", GetLastError());
|
||||
|
||||
ok(dwDataLen == sizeof(expected_exported_priv_key), "unexpected size %d\n",
|
||||
dwDataLen);
|
||||
todo_wine
|
||||
ok(!memcmp(exported_key, expected_exported_priv_key, dwDataLen),
|
||||
"unexpected value\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, exported_key);
|
||||
|
||||
CryptDestroyKey(hPrivKey);
|
||||
}
|
||||
|
||||
static void test_schannel_provider(void)
|
||||
|
Loading…
Reference in New Issue
Block a user