crypt32: Fix typo in key context property test, and the problems it hid.
This commit is contained in:
parent
90824039ac
commit
5885eb3cc3
|
@ -476,8 +476,14 @@ static BOOL WINAPI CertContext_SetProperty(void *context, DWORD dwPropId,
|
||||||
{
|
{
|
||||||
const CERT_KEY_CONTEXT *keyContext = (const CERT_KEY_CONTEXT *)pvData;
|
const CERT_KEY_CONTEXT *keyContext = (const CERT_KEY_CONTEXT *)pvData;
|
||||||
|
|
||||||
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
if (keyContext->cbSize != sizeof(CERT_KEY_CONTEXT))
|
||||||
(const BYTE *)keyContext, keyContext->cbSize);
|
{
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ContextPropertyList_SetProperty(properties, dwPropId,
|
||||||
|
(const BYTE *)keyContext, keyContext->cbSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -334,7 +334,6 @@ static void testCertProperties(void)
|
||||||
BYTE hash[20] = { 0 }, hashProperty[20];
|
BYTE hash[20] = { 0 }, hashProperty[20];
|
||||||
CRYPT_DATA_BLOB blob;
|
CRYPT_DATA_BLOB blob;
|
||||||
CERT_KEY_CONTEXT keyContext;
|
CERT_KEY_CONTEXT keyContext;
|
||||||
HCRYPTPROV csp;
|
|
||||||
|
|
||||||
ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
|
ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
|
||||||
GetLastError());
|
GetLastError());
|
||||||
|
@ -442,50 +441,38 @@ static void testCertProperties(void)
|
||||||
context->pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData,
|
context->pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData,
|
||||||
CALG_MD5, context, CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID);
|
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;
|
size = 0;
|
||||||
ret = CertGetCertificateContextProperty(context,
|
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
NULL, &size);
|
||||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||||
size = sizeof(CERT_KEY_CONTEXT);
|
size = sizeof(CERT_KEY_CONTEXT);
|
||||||
ret = CertGetCertificateContextProperty(context,
|
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
|
NULL, &size);
|
||||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||||
ret = CertGetCertificateContextProperty(context,
|
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, &keyContext, &size);
|
&keyContext, &size);
|
||||||
ok(!ret && GetLastError() == ERROR_INVALID_DATA,
|
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||||
"Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
|
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||||
/* Key context with an invalid size */
|
/* Key context with an invalid size */
|
||||||
keyContext.cbSize = 0;
|
keyContext.cbSize = 0;
|
||||||
ret = CertSetCertificateContextProperty(context,
|
ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, 0, &keyContext);
|
0, &keyContext);
|
||||||
ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
|
ok(!ret && GetLastError() == E_INVALIDARG,
|
||||||
GetLastError());
|
"Expected E_INVALIDARG, got %08x\n", GetLastError());
|
||||||
size = sizeof(keyContext);
|
size = sizeof(keyContext);
|
||||||
ret = CertGetCertificateContextProperty(context,
|
ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, &keyContext, &size);
|
&keyContext, &size);
|
||||||
ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
|
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
|
||||||
GetLastError());
|
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
|
||||||
keyContext.cbSize = sizeof(keyContext);
|
keyContext.cbSize = sizeof(keyContext);
|
||||||
keyContext.hCryptProv = 0;
|
keyContext.hCryptProv = 0;
|
||||||
keyContext.dwKeySpec = AT_SIGNATURE;
|
keyContext.dwKeySpec = AT_SIGNATURE;
|
||||||
/* Crash
|
ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
|
||||||
ret = CertSetCertificateContextProperty(context,
|
0, &keyContext);
|
||||||
CERT_KEY_IDENTIFIER_PROP_ID, 0, &keyContext);
|
ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
|
||||||
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());
|
|
||||||
/* Now that that's set, the key prov handle property is also gettable.
|
/* Now that that's set, the key prov handle property is also gettable.
|
||||||
*/
|
*/
|
||||||
size = sizeof(DWORD);
|
size = sizeof(DWORD);
|
||||||
|
@ -506,8 +493,6 @@ static void testCertProperties(void)
|
||||||
GetLastError());
|
GetLastError());
|
||||||
ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n");
|
ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n");
|
||||||
|
|
||||||
CryptReleaseContext(csp, 0);
|
|
||||||
|
|
||||||
CertFreeCertificateContext(context);
|
CertFreeCertificateContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue