Commit 5df2626a authored by Jeremy White's avatar Jeremy White Committed by Alexandre Julliard

advapi32/tests: Only release providers and free keys if we've had success creating them.

parent 39d8f137
......@@ -956,7 +956,8 @@ static void test_rc2_keylen(void)
ret = pCryptAcquireContextA(&provider, NULL, NULL,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContext error %u\n", GetLastError());
if (ret)
{
key_blob.header.bType = PLAINTEXTKEYBLOB;
key_blob.header.bVersion = CUR_BLOB_VERSION;
key_blob.header.reserved = 0;
......@@ -975,14 +976,18 @@ static void test_rc2_keylen(void)
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
"CryptImportKey error %08x\n", GetLastError());
if (ret)
pCryptDestroyKey(hkey);
pCryptReleaseContext(provider, 0);
}
SetLastError(0xdeadbeef);
ret = pCryptAcquireContextA(&provider, NULL, MS_DEF_PROV,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContext error %08x\n", GetLastError());
if (ret)
{
/* Importing a 16-byte key doesn't work with the base provider.. */
SetLastError(0xdeadbeef);
ret = pCryptImportKey(provider, (BYTE*)&key_blob,
......@@ -1003,6 +1008,7 @@ static void test_rc2_keylen(void)
broken(!ret && GetLastError() == NTE_BAD_TYPE) || /* W2K */
broken(!ret && GetLastError() == NTE_PERM), /* Win9x, WinMe and NT4 */
"CryptAcquireContext error %08x\n", GetLastError());
if (ret)
pCryptDestroyKey(hkey);
/* as does importing a 16-byte key with the base provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
......@@ -1017,9 +1023,11 @@ static void test_rc2_keylen(void)
ok(ret ||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
"CryptImportKey error %08x\n", GetLastError());
if (ret)
pCryptDestroyKey(hkey);
pCryptReleaseContext(provider, 0);
}
key_blob.key_size = sizeof(key);
SetLastError(0xdeadbeef);
......@@ -1027,6 +1035,8 @@ static void test_rc2_keylen(void)
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
ok(ret, "CryptAcquireContext error %08x\n", GetLastError());
if (ret)
{
/* Importing a 16-byte key also works with the default provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
......@@ -1038,6 +1048,7 @@ static void test_rc2_keylen(void)
ok(ret ||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
"CryptImportKey error %08x\n", GetLastError());
if (ret)
pCryptDestroyKey(hkey);
/* There is no apparent limit to the size of the input key when
......@@ -1052,9 +1063,11 @@ static void test_rc2_keylen(void)
ok(ret ||
broken(!ret && GetLastError() == NTE_BAD_FLAGS),
"CryptImportKey error %08x\n", GetLastError());
if (ret)
pCryptDestroyKey(hkey);
pCryptReleaseContext(provider, 0);
}
}
START_TEST(crypt)
......
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