rsaenh: Use the correct registry key in RSAENH_CPAcquireContext.

This commit is contained in:
Mounir IDRASSI 2007-05-07 23:37:30 +02:00 committed by Alexandre Julliard
parent 526d2b4c33
commit 56a1326a8b
2 changed files with 26 additions and 1 deletions

View File

@ -1476,7 +1476,12 @@ BOOL WINAPI RSAENH_CPAcquireContext(HCRYPTPROV *phProv, LPSTR pszContainer,
SetLastError(NTE_BAD_KEYSET_PARAM);
return FALSE;
} else {
if (!RegDeleteKeyA(HKEY_CURRENT_USER, szRegKey)) {
HKEY hRootKey;
if (dwFlags & CRYPT_MACHINE_KEYSET)
hRootKey = HKEY_LOCAL_MACHINE;
else
hRootKey = HKEY_CURRENT_USER;
if (!RegDeleteKeyA(hRootKey, szRegKey)) {
SetLastError(ERROR_SUCCESS);
return TRUE;
} else {

View File

@ -1623,6 +1623,26 @@ static void test_null_provider(void)
CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_DELETEKEYSET);
/* test the machine key set */
CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET);
result = CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET);
ok(result, "CryptAcquireContext with CRYPT_MACHINE_KEYSET failed: %08x\n", GetLastError());
CryptReleaseContext(prov, 0);
result = CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_MACHINE_KEYSET);
ok(result, "CryptAcquireContext with CRYPT_MACHINE_KEYSET failed: %08x\n", GetLastError());
CryptReleaseContext(prov,0);
result = CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET);
ok(result, "CryptAcquireContext with CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET failed: %08x\n",
GetLastError());
result = CryptAcquireContext(&prov, szContainer, NULL, PROV_RSA_FULL,
CRYPT_MACHINE_KEYSET);
ok(!result && GetLastError() == NTE_BAD_KEYSET ,
"Expected NTE_BAD_KEYSET, got %08x\n", GetLastError());
}
START_TEST(rsaenh)