Commit 0eb9ae17 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

rsaenh: Fix CryptSetKeyParam for KP_PERMISSIONS.

parent 1cc58867
......@@ -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);
......
......@@ -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,"
......
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