advapi32: CryptCreateHash actually sets ERROR_INVALID_PARAMETER if the CSP handle is 0.

This commit is contained in:
Johan Gill 2012-02-14 12:15:04 +01:00 committed by Alexandre Julliard
parent 454467dc93
commit 16dc83578a
2 changed files with 4 additions and 6 deletions

View File

@ -720,12 +720,7 @@ BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
TRACE("(0x%lx, 0x%x, 0x%lx, %08x, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
if (!prov)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!phHash || prov->dwMagic != MAGIC_CRYPTPROV ||
if (!prov || !phHash || prov->dwMagic != MAGIC_CRYPTPROV ||
(key && key->dwMagic != MAGIC_CRYPTKEY))
{
SetLastError(ERROR_INVALID_PARAMETER);

View File

@ -238,6 +238,9 @@ static void test_incorrect_api_usage(void)
if (!result) return;
pCryptDestroyHash(hHash);
result = pCryptCreateHash(0, CALG_SHA, 0, 0, &hHash);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = pCryptGenKey(0, CALG_RC4, 0, &hKey);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());