Commit d59011a9 authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

rsaenh: A 40 bit key on Enhanced provider will not have salt even if asked for.

parent d7aae7d7
......@@ -873,6 +873,7 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
destroy_key, (OBJECTHDR**)&pCryptKey);
if (hCryptKey != (HCRYPTKEY)INVALID_HANDLE_VALUE)
{
KEYCONTAINER *pKeyContainer = get_key_container(hProv);
pCryptKey->aiAlgid = aiAlgid;
pCryptKey->hProv = hProv;
pCryptKey->dwModeBits = 0;
......@@ -882,7 +883,16 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
pCryptKey->dwPermissions |= CRYPT_EXPORT;
pCryptKey->dwKeyLen = dwKeyLen >> 3;
pCryptKey->dwEffectiveKeyLen = 0;
if ((dwFlags & CRYPT_CREATE_SALT) || (dwKeyLen == 40 && !(dwFlags & CRYPT_NO_SALT)))
/*
* For compatibility reasons a 40 bit key on the Enhanced
* provider will not have salt
*/
if (pKeyContainer->dwPersonality == RSAENH_PERSONALITY_ENHANCED
&& (aiAlgid == CALG_RC2 || aiAlgid == CALG_RC4)
&& (dwFlags & CRYPT_CREATE_SALT) && dwKeyLen == 40)
pCryptKey->dwSaltLen = 0;
else if ((dwFlags & CRYPT_CREATE_SALT) || (dwKeyLen == 40 && !(dwFlags & CRYPT_NO_SALT)))
pCryptKey->dwSaltLen = 16 /*FIXME*/ - pCryptKey->dwKeyLen;
else
pCryptKey->dwSaltLen = 0;
......
......@@ -1604,22 +1604,10 @@ static void test_rc2(void)
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
if(result)
{
/* Remove IF when fixed */
if(ENHANCED_PROV)
{
todo_wine
ok((ENHANCED_PROV && !memcmp(pbData, rc2_40_salt_enh, dwDataLen)) ||
(STRONG_PROV && !memcmp(pbData, rc2_40_salt_strong, dwDataLen)) ||
(BASE_PROV && !memcmp(pbData, rc2_40_salt_base, dwDataLen)),
"RC2 encryption failed!\n");
}
else
{
ok((ENHANCED_PROV && !memcmp(pbData, rc2_40_salt_enh, dwDataLen)) ||
(STRONG_PROV && !memcmp(pbData, rc2_40_salt_strong, dwDataLen)) ||
(BASE_PROV && !memcmp(pbData, rc2_40_salt_base, dwDataLen)),
"RC2 encryption failed!\n");
}
}
else /* <= XP */
{
......@@ -1640,7 +1628,6 @@ static void test_rc2(void)
if (!ENHANCED_PROV)
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
else
todo_wine
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
result = CryptDestroyKey(hKey);
......@@ -1778,20 +1765,9 @@ static void test_rc4(void)
SetLastError(0xdeadbeef);
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
ok(result, "%08x\n", GetLastError());
/* Remove IF when fixed */
if (ENHANCED_PROV)
{
todo_wine
ok((ENHANCED_PROV && !memcmp(pbData, rc4_40_salt, dwDataLen)) ||
(!ENHANCED_PROV && !memcmp(pbData, rc4_40_salt_base, dwDataLen)),
"RC4 encryption failed!\n");
}
else
{
ok((ENHANCED_PROV && !memcmp(pbData, rc4_40_salt, dwDataLen)) ||
(!ENHANCED_PROV && !memcmp(pbData, rc4_40_salt_base, dwDataLen)),
"RC4 encryption failed!\n");
}
dwLen = sizeof(DWORD);
dwKeyLen = 12345;
......@@ -1806,7 +1782,6 @@ static void test_rc4(void)
if (!ENHANCED_PROV)
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
else
todo_wine
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
result = CryptDestroyKey(hKey);
......
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