rsaenh/tests: Update some tests.
Some function results and out parameters were not being tested.
This commit is contained in:
parent
edb5e2b7d5
commit
aa1b5b65c9
|
@ -928,6 +928,7 @@ static void test_des(void)
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwMode == CRYPT_MODE_ECB, "Expected CRYPT_MODE_ECB, got %d\n", dwMode);
|
||||||
|
|
||||||
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
|
for (i=0; i<sizeof(pbData); i++) pbData[i] = (unsigned char)i;
|
||||||
|
|
||||||
|
@ -1358,8 +1359,7 @@ static void test_rc2(void)
|
||||||
HCRYPTKEY hKey;
|
HCRYPTKEY hKey;
|
||||||
BOOL result;
|
BOOL result;
|
||||||
DWORD dwLen, dwKeyLen, dwDataLen, dwMode, dwModeBits;
|
DWORD dwLen, dwKeyLen, dwDataLen, dwMode, dwModeBits;
|
||||||
BYTE *pbTemp;
|
unsigned char pbData[2000], pbHashValue[16], pszBuffer[256];
|
||||||
unsigned char pbData[2000], pbHashValue[16];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i<2000; i++) pbData[i] = (unsigned char)i;
|
for (i=0; i<2000; i++) pbData[i] = (unsigned char)i;
|
||||||
|
@ -1417,26 +1417,30 @@ static void test_rc2(void)
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwModeBits, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwModeBits, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwLen == 4, "Expected 4, got %d\n", dwLen);
|
||||||
|
|
||||||
|
dwLen = 0;
|
||||||
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
|
result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0);
|
||||||
CryptGetKeyParam(hKey, KP_IV, pbTemp, &dwLen, 0);
|
ok(result, "%08x\n", GetLastError());
|
||||||
HeapFree(GetProcessHeap(), 0, pbTemp);
|
ok(dwLen == 8, "Expected 8, got %d\n", dwLen);
|
||||||
|
|
||||||
|
dwLen = 0;
|
||||||
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
/* The default salt length is always 11... */
|
/* The default salt length is always 11... */
|
||||||
ok(dwLen == 11, "unexpected salt length %d\n", dwLen);
|
ok(dwLen == 11, "unexpected salt length %d\n", dwLen);
|
||||||
/* and the default salt is always empty. */
|
/* and the default salt is always empty. */
|
||||||
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
|
result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0);
|
||||||
CryptGetKeyParam(hKey, KP_SALT, pbTemp, &dwLen, 0);
|
ok(result, "%08x\n", GetLastError());
|
||||||
for (i=0; i<dwLen; i++)
|
for (i=0; i<dwLen; i++)
|
||||||
ok(!pbTemp[i], "unexpected salt value %02x @ %d\n", pbTemp[i], i);
|
ok(!pszBuffer[i], "unexpected salt value %02x @ %d\n", pszBuffer[i], i);
|
||||||
HeapFree(GetProcessHeap(), 0, pbTemp);
|
|
||||||
|
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
||||||
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwMode == CRYPT_MODE_CBC, "Expected CRYPT_MODE_CBC, got %d\n", dwMode);
|
||||||
|
|
||||||
result = CryptDestroyHash(hHash);
|
result = CryptDestroyHash(hHash);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
@ -1447,11 +1451,11 @@ static void test_rc2(void)
|
||||||
|
|
||||||
ok(!memcmp(pbData, rc2_40_encrypted, 16), "RC2 encryption failed!\n");
|
ok(!memcmp(pbData, rc2_40_encrypted, 16), "RC2 encryption failed!\n");
|
||||||
|
|
||||||
|
dwLen = 0;
|
||||||
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
|
result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0);
|
||||||
CryptGetKeyParam(hKey, KP_IV, pbTemp, &dwLen, 0);
|
ok(result, "%08x\n", GetLastError());
|
||||||
HeapFree(GetProcessHeap(), 0, pbTemp);
|
|
||||||
|
|
||||||
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
|
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
@ -1519,22 +1523,30 @@ static void test_rc2(void)
|
||||||
ok(!result, "CryptSetKeyParam failed: %08x\n", GetLastError());
|
ok(!result, "CryptSetKeyParam failed: %08x\n", GetLastError());
|
||||||
|
|
||||||
dwLen = sizeof(dwKeyLen);
|
dwLen = sizeof(dwKeyLen);
|
||||||
CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
||||||
|
ok(result, "%08x", GetLastError());
|
||||||
ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError());
|
ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError());
|
||||||
CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
||||||
|
ok(result, "%08x", GetLastError());
|
||||||
ok(dwKeyLen == 56 || broken(dwKeyLen == 40), "%d (%08x)\n", dwKeyLen, GetLastError());
|
ok(dwKeyLen == 56 || broken(dwKeyLen == 40), "%d (%08x)\n", dwKeyLen, GetLastError());
|
||||||
|
|
||||||
dwKeyLen = 128;
|
dwKeyLen = 128;
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (LPBYTE)&dwKeyLen, 0);
|
result = CryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (LPBYTE)&dwKeyLen, 0);
|
||||||
if (!BASE_PROV)
|
if (!BASE_PROV)
|
||||||
ok(result, "expected success, got error 0x%08X\n", GetLastError());
|
ok(result, "expected success, got error 0x%08X\n", GetLastError());
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ok(!result, "expected error\n");
|
ok(!result, "expected error\n");
|
||||||
|
ok(GetLastError() == NTE_BAD_DATA, "Expected 0x80009005, got 0x%08X\n", GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
dwLen = sizeof(dwKeyLen);
|
dwLen = sizeof(dwKeyLen);
|
||||||
CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
||||||
|
ok(result, "%08x", GetLastError());
|
||||||
ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError());
|
ok(dwKeyLen == 56, "%d (%08x)\n", dwKeyLen, GetLastError());
|
||||||
CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&dwKeyLen, &dwLen, 0);
|
||||||
|
ok(result, "%08x", GetLastError());
|
||||||
/* Remove IF when fixed */
|
/* Remove IF when fixed */
|
||||||
if(BASE_PROV)
|
if(BASE_PROV)
|
||||||
{
|
{
|
||||||
|
@ -1587,7 +1599,7 @@ static void test_rc4(void)
|
||||||
HCRYPTHASH hHash;
|
HCRYPTHASH hHash;
|
||||||
HCRYPTKEY hKey;
|
HCRYPTKEY hKey;
|
||||||
DWORD dwDataLen = 5, dwKeyLen, dwLen = sizeof(DWORD), dwMode;
|
DWORD dwDataLen = 5, dwKeyLen, dwLen = sizeof(DWORD), dwMode;
|
||||||
unsigned char pbData[2000], *pbTemp;
|
unsigned char pbData[2000];
|
||||||
unsigned char pszBuffer[256];
|
unsigned char pszBuffer[256];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1614,25 +1626,29 @@ static void test_rc4(void)
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_KEYLEN, (BYTE*)&dwKeyLen, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwKeyLen == 56, "Expected 56, got %d\n", dwKeyLen);
|
||||||
|
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwKeyLen, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_BLOCKLEN, (BYTE*)&dwKeyLen, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwKeyLen == 0, "Expected 0, got %d\n", dwKeyLen);
|
||||||
|
|
||||||
|
dwLen = 0;
|
||||||
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_IV, NULL, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
|
result = CryptGetKeyParam(hKey, KP_IV, pszBuffer, &dwLen, 0);
|
||||||
CryptGetKeyParam(hKey, KP_IV, pbTemp, &dwLen, 0);
|
|
||||||
HeapFree(GetProcessHeap(), 0, pbTemp);
|
|
||||||
|
|
||||||
|
dwLen = 0;
|
||||||
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
pbTemp = HeapAlloc(GetProcessHeap(), 0, dwLen);
|
result = CryptGetKeyParam(hKey, KP_SALT, pszBuffer, &dwLen, 0);
|
||||||
CryptGetKeyParam(hKey, KP_SALT, pbTemp, &dwLen, 0);
|
ok(result, "%08x\n", GetLastError());
|
||||||
HeapFree(GetProcessHeap(), 0, pbTemp);
|
|
||||||
|
|
||||||
dwLen = sizeof(DWORD);
|
dwLen = sizeof(DWORD);
|
||||||
CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&dwMode, &dwLen, 0);
|
||||||
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
ok(dwMode == 0 || broken(dwMode == CRYPT_MODE_CBC) /* <= 2000 */,
|
||||||
|
"Expected 0, got %d\n", dwMode);
|
||||||
|
|
||||||
result = CryptDestroyHash(hHash);
|
result = CryptDestroyHash(hHash);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
|
@ -3697,7 +3713,7 @@ START_TEST(rsaenh)
|
||||||
for (iProv = 0; iProv < sizeof(szProviders) / sizeof(szProviders[0]); iProv++)
|
for (iProv = 0; iProv < sizeof(szProviders) / sizeof(szProviders[0]); iProv++)
|
||||||
{
|
{
|
||||||
if (!init_base_environment(szProviders[iProv], 0))
|
if (!init_base_environment(szProviders[iProv], 0))
|
||||||
return;
|
continue;
|
||||||
trace("Testing '%s'\n", szProviders[iProv]);
|
trace("Testing '%s'\n", szProviders[iProv]);
|
||||||
test_prov();
|
test_prov();
|
||||||
test_gen_random();
|
test_gen_random();
|
||||||
|
@ -3725,6 +3741,7 @@ START_TEST(rsaenh)
|
||||||
if(!BASE_PROV) test_key_derivation(STRONG_PROV ? "STRONG" : "ENH");
|
if(!BASE_PROV) test_key_derivation(STRONG_PROV ? "STRONG" : "ENH");
|
||||||
clean_up_base_environment();
|
clean_up_base_environment();
|
||||||
}
|
}
|
||||||
|
if (!init_base_environment(MS_ENHANCED_PROV_A, 0))
|
||||||
test_key_permissions();
|
test_key_permissions();
|
||||||
test_key_initialization();
|
test_key_initialization();
|
||||||
test_schannel_provider();
|
test_schannel_provider();
|
||||||
|
|
Loading…
Reference in New Issue