mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
crypt32: Fix typo in key context property test, and the problems it hid.
This commit is contained in:
parent
90824039ac
commit
5885eb3cc3
2 changed files with 32 additions and 41 deletions
|
@ -476,8 +476,14 @@ static BOOL WINAPI CertContext_SetProperty(void *context, DWORD dwPropId,
|
|||
{
|
||||
const CERT_KEY_CONTEXT *keyContext = (const CERT_KEY_CONTEXT *)pvData;
|
||||
|
||||
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
||||
(const BYTE *)keyContext, keyContext->cbSize);
|
||||
if (keyContext->cbSize != sizeof(CERT_KEY_CONTEXT))
|
||||
{
|
||||
SetLastError(E_INVALIDARG);
|
||||
ret = FALSE;
|
||||
}
|
||||
else
|
||||
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
||||
(const BYTE *)keyContext, keyContext->cbSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -334,7 +334,6 @@ static void testCertProperties(void)
|
|||
BYTE hash[20] = { 0 }, hashProperty[20];
|
||||
CRYPT_DATA_BLOB blob;
|
||||
CERT_KEY_CONTEXT keyContext;
|
||||
HCRYPTPROV csp;
|
||||
|
||||
ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
|
||||
GetLastError());
|
||||
|
@ -442,50 +441,38 @@ static void testCertProperties(void)
|
|||
context->pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData,
|
||||
CALG_MD5, context, CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID);
|
||||
|
||||
/* Test key identifiers and handles and such */
|
||||
/* Test key contexts and handles and such */
|
||||
size = 0;
|
||||
ret = CertGetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
||||
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
NULL, &size);
|
||||
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||
size = sizeof(CERT_KEY_CONTEXT);
|
||||
ret = CertGetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
||||
ret = CertGetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, &keyContext, &size);
|
||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
||||
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
NULL, &size);
|
||||
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
&keyContext, &size);
|
||||
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||
/* Key context with an invalid size */
|
||||
keyContext.cbSize = 0;
|
||||
ret = CertSetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, 0, &keyContext);
|
||||
ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
|
||||
GetLastError());
|
||||
ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
0, &keyContext);
|
||||
ok(!ret && GetLastError() == E_INVALIDARG,
|
||||
"Expected E_INVALIDARG, got %08x\n", GetLastError());
|
||||
size = sizeof(keyContext);
|
||||
ret = CertGetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, &keyContext, &size);
|
||||
ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
|
||||
GetLastError());
|
||||
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
&keyContext, &size);
|
||||
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||
keyContext.cbSize = sizeof(keyContext);
|
||||
keyContext.hCryptProv = 0;
|
||||
keyContext.dwKeySpec = AT_SIGNATURE;
|
||||
/* Crash
|
||||
ret = CertSetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, 0, &keyContext);
|
||||
ret = CertSetCertificateContextProperty(context,
|
||||
CERT_KEY_IDENTIFIER_PROP_ID, CERT_STORE_NO_CRYPT_RELEASE_FLAG,
|
||||
&keyContext);
|
||||
*/
|
||||
ret = CryptAcquireContextW(&csp, cspNameW,
|
||||
MS_DEF_PROV_W, PROV_RSA_FULL, CRYPT_NEWKEYSET);
|
||||
ok(ret, "CryptAcquireContextW failed: %08x\n", GetLastError());
|
||||
keyContext.hCryptProv = csp;
|
||||
ret = CertSetCertificateContextProperty(context,
|
||||
CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext);
|
||||
ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
|
||||
GetLastError());
|
||||
ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||
0, &keyContext);
|
||||
ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
|
||||
/* Now that that's set, the key prov handle property is also gettable.
|
||||
*/
|
||||
size = sizeof(DWORD);
|
||||
|
@ -506,8 +493,6 @@ static void testCertProperties(void)
|
|||
GetLastError());
|
||||
ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n");
|
||||
|
||||
CryptReleaseContext(csp, 0);
|
||||
|
||||
CertFreeCertificateContext(context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue