rsaenh: Support setting salt via KP_SALT (resend).

This commit is contained in:
Juan Lang 2010-03-30 10:26:48 -07:00 committed by Alexandre Julliard
parent ece32e7f12
commit c5a6b7b366
2 changed files with 27 additions and 3 deletions

View File

@ -3354,6 +3354,33 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam
setup_key(pCryptKey);
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:
{
CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pbData;

View File

@ -986,13 +986,11 @@ static void test_rc2(void)
/* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
todo_wine
ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */
dwLen = 0;
result = CryptGetKeyParam(hKey, KP_SALT, NULL, &dwLen, 0);
ok(result, "%08x\n", GetLastError());
todo_wine
ok(dwLen == 0, "unexpected salt length %d\n", dwLen);
/* What sizes salt can I set? */
salt.pbData = pbData;
@ -1154,7 +1152,6 @@ static void test_rc4(void)
/* Setting the salt also succeeds... */
result = CryptSetKeyParam(hKey, KP_SALT, pbData, 0);
todo_wine
ok(result, "setting salt failed: %08x\n", GetLastError());
/* but the resulting salt length is now zero? */
dwLen = 0;