Commit 7d4eaa30 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

advapi32: Return ERROR_INVALID_PARAMETER for invalid crypt objects' handles.

parent eca2bfd0
......@@ -152,6 +152,9 @@ static void test_CryptReleaseContext(void)
ret = CryptContextAddRef(prov, NULL, 0);
ok(ret, "got %u\n", GetLastError());
ret = CryptContextAddRef(0, NULL, 0);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
ret = CryptReleaseContext(prov, 0);
ok(ret, "got %u\n", GetLastError());
......@@ -272,18 +275,49 @@ static void test_incorrect_api_usage(void)
result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash);
ok (result, "%d\n", GetLastError());
if (!result) return;
CryptDestroyHash(hHash);
result = CryptCreateHash(0, CALG_SHA, 0, 0, &hHash);
result = CryptDeriveKey(0, CALG_RC4, hHash, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGenKey(0, CALG_RC4, 0, &hKey);
result = CryptDeriveKey(hProv, CALG_RC4, 0, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptHashData(0, &temp, 1, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGenKey(hProv, CALG_RC4, 0, &hKey);
ok (result, "%d\n", GetLastError());
if (!result) return;
result = pCryptHashSessionKey(hHash, 0, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = pCryptHashSessionKey(0, hKey, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptDestroyHash(hHash);
ok (result, "%08x\n", GetLastError());
result = CryptDestroyHash(0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptCreateHash(0, CALG_SHA, 0, 0, &hHash);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGenKey(0, CALG_RC4, 0, &hKey);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
dwLen = 1;
result = CryptDecrypt(hKey, 0, TRUE, 0, &temp, &dwLen);
ok (result, "%d\n", GetLastError());
result = CryptDecrypt(0, 0, TRUE, 0, &temp, &dwLen);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptEncrypt(hKey, 0, TRUE, 0, &temp, &dwLen, sizeof(temp));
ok (result, "%d\n", GetLastError());
result = CryptEncrypt(0, 0, TRUE, 0, &temp, &dwLen, sizeof(temp));
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptDestroyKey(hKey);
ok (result, "%d\n", GetLastError());
......@@ -294,6 +328,9 @@ static void test_incorrect_api_usage(void)
result = CryptDestroyKey(hKey2);
ok (result, "%d\n", GetLastError());
result = CryptDestroyKey(0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
dwTemp = CRYPT_MODE_ECB;
result = CryptSetKeyParam(hKey2, KP_MODE, (BYTE*)&dwTemp, sizeof(DWORD));
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
......@@ -309,6 +346,9 @@ static void test_incorrect_api_usage(void)
ok(result, "got %u\n", GetLastError());
if (!result) return;
result = pCryptGenRandom(0, 1, &temp);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = pCryptGenRandom(hProv, 1, &temp);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
......@@ -353,6 +393,9 @@ static void test_incorrect_api_usage(void)
dwLen = 1;
result = CryptGetProvParam(hProv, 0, &temp, &dwLen, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGetUserKey(0, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGetUserKey(hProv, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
......@@ -372,6 +415,9 @@ static void test_incorrect_api_usage(void)
result = pCryptSignHashW(hHash, 0, NULL, 0, &temp, &dwLen);
ok (!result && (GetLastError() == ERROR_INVALID_PARAMETER ||
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
result = pCryptSignHashW(hHash, 0, NULL, 0, &temp, &dwLen);
ok (!result && (GetLastError() == ERROR_INVALID_PARAMETER ||
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
}
else
win_skip("CryptSignHashW is not available\n");
......@@ -382,6 +428,9 @@ static void test_incorrect_api_usage(void)
result = CryptSetHashParam(hHash, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptSetProvParam(0, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptSetProvParam(hProv, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment