rsaenh: Fix CryptSetKeyParam for KP_PERMISSIONS.

This commit is contained in:
Juan Lang 2009-01-28 20:31:35 -08:00 committed by Alexandre Julliard
parent 1cc5886771
commit 0eb9ae17fe
2 changed files with 19 additions and 5 deletions

View File

@ -2824,8 +2824,26 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam
return TRUE;
case KP_PERMISSIONS:
pCryptKey->dwPermissions = *(DWORD*)pbData;
{
DWORD perms = *(DWORD *)pbData;
if ((perms & CRYPT_EXPORT) &&
!(pCryptKey->dwPermissions & CRYPT_EXPORT))
{
SetLastError(NTE_BAD_DATA);
return FALSE;
}
else if (!(perms & CRYPT_EXPORT) &&
(pCryptKey->dwPermissions & CRYPT_EXPORT))
{
/* Clearing the export permission appears to be ignored,
* see tests.
*/
perms |= CRYPT_EXPORT;
}
pCryptKey->dwPermissions = perms;
return TRUE;
}
case KP_IV:
memcpy(pCryptKey->abInitVector, pbData, pCryptKey->dwBlockLen);

View File

@ -1581,7 +1581,6 @@ static void test_rsa_encrypt(void)
dwVal |= CRYPT_EXPORT;
SetLastError(0xdeadbeef);
result = CryptSetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE *)&dwVal, 0);
todo_wine
ok(!result && GetLastError() == NTE_BAD_DATA,
"expected NTE_BAD_DATA, got %08x\n", GetLastError());
@ -1614,7 +1613,6 @@ static void test_rsa_encrypt(void)
dwVal |= CRYPT_EXPORT;
SetLastError(0xdeadbeef);
result = CryptSetKeyParam(hRSAKey, KP_PERMISSIONS, (BYTE *)&dwVal, 0);
todo_wine
ok(!result && GetLastError() == NTE_BAD_DATA,
"expected NTE_BAD_DATA, got %08x\n", GetLastError());
@ -2157,7 +2155,6 @@ static void test_key_permissions(void)
dwLen = sizeof(DWORD);
result = CryptGetKeyParam(hKey1, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
todo_wine
ok(dwVal ==
(CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT),
"expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT,"
@ -2178,7 +2175,6 @@ static void test_key_permissions(void)
dwLen = sizeof(DWORD);
result = CryptGetKeyParam(hKey2, KP_PERMISSIONS, (BYTE*)&dwVal, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
todo_wine
ok(dwVal ==
(CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT),
"expected CRYPT_MAC|CRYPT_WRITE|CRYPT_READ|CRYPT_EXPORT|CRYPT_DECRYPT|CRYPT_ENCRYPT,"