Commit c5a6b7b3 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

rsaenh: Support setting salt via KP_SALT (resend).

parent ece32e7f
...@@ -3354,6 +3354,33 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam ...@@ -3354,6 +3354,33 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam
setup_key(pCryptKey); setup_key(pCryptKey);
return TRUE; return TRUE;
case KP_SALT:
switch (pCryptKey->aiAlgid) {
case CALG_RC2:
case CALG_RC4:
if (!pbData)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
/* MSDN: the base provider always sets eleven bytes of
* salt value.
*/
memcpy(pCryptKey->abKeyValue + pCryptKey->dwKeyLen,
pbData, 11);
pCryptKey->dwSaltLen = 11;
setup_key(pCryptKey);
/* Strange but true: salt length reset to 0 after setting
* it via KP_SALT.
*/
pCryptKey->dwSaltLen = 0;
break;
default:
SetLastError(NTE_BAD_KEY);
return FALSE;
}
return TRUE;
case KP_SALT_EX: case KP_SALT_EX:
{ {
CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pbData; CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pbData;
......
...@@ -986,13 +986,11 @@ static void test_rc2(void) ...@@ -986,13 +986,11 @@ static void test_rc2(void)
/* Setting the salt also succeeds... */ /* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0); result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
todo_wine
ok(result, "setting salt failed: %08x\n", GetLastError()); ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */ /* but the resulting salt length is now zero? */
dwLen = 0; 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());
todo_wine
ok(dwLen == 0, "unexpected salt length %d\n", dwLen); ok(dwLen == 0, "unexpected salt length %d\n", dwLen);
/* What sizes salt can I set? */ /* What sizes salt can I set? */
salt.pbData = pbData; salt.pbData = pbData;
...@@ -1154,7 +1152,6 @@ static void test_rc4(void) ...@@ -1154,7 +1152,6 @@ static void test_rc4(void)
/* Setting the salt also succeeds... */ /* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0); result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
todo_wine
ok(result, "setting salt failed: %08x\n", GetLastError()); ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */ /* but the resulting salt length is now zero? */
dwLen = 0; dwLen = 0;
......
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