mirror of
https://github.com/reactos/wine.git
synced 2025-02-23 06:12:31 +00:00
rsaenh: A 40 bit key on Enhanced provider will not have salt even if asked for.
This commit is contained in:
parent
d7aae7d728
commit
d59011a9fb
@ -873,6 +873,7 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
|
|||||||
destroy_key, (OBJECTHDR**)&pCryptKey);
|
destroy_key, (OBJECTHDR**)&pCryptKey);
|
||||||
if (hCryptKey != (HCRYPTKEY)INVALID_HANDLE_VALUE)
|
if (hCryptKey != (HCRYPTKEY)INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
KEYCONTAINER *pKeyContainer = get_key_container(hProv);
|
||||||
pCryptKey->aiAlgid = aiAlgid;
|
pCryptKey->aiAlgid = aiAlgid;
|
||||||
pCryptKey->hProv = hProv;
|
pCryptKey->hProv = hProv;
|
||||||
pCryptKey->dwModeBits = 0;
|
pCryptKey->dwModeBits = 0;
|
||||||
@ -882,7 +883,16 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
|
|||||||
pCryptKey->dwPermissions |= CRYPT_EXPORT;
|
pCryptKey->dwPermissions |= CRYPT_EXPORT;
|
||||||
pCryptKey->dwKeyLen = dwKeyLen >> 3;
|
pCryptKey->dwKeyLen = dwKeyLen >> 3;
|
||||||
pCryptKey->dwEffectiveKeyLen = 0;
|
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;
|
pCryptKey->dwSaltLen = 16 /*FIXME*/ - pCryptKey->dwKeyLen;
|
||||||
else
|
else
|
||||||
pCryptKey->dwSaltLen = 0;
|
pCryptKey->dwSaltLen = 0;
|
||||||
|
@ -1604,22 +1604,10 @@ static void test_rc2(void)
|
|||||||
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
|
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
|
||||||
if(result)
|
if(result)
|
||||||
{
|
{
|
||||||
/* Remove IF when fixed */
|
|
||||||
if(ENHANCED_PROV)
|
|
||||||
{
|
|
||||||
todo_wine
|
|
||||||
ok((ENHANCED_PROV && !memcmp(pbData, rc2_40_salt_enh, dwDataLen)) ||
|
ok((ENHANCED_PROV && !memcmp(pbData, rc2_40_salt_enh, dwDataLen)) ||
|
||||||
(STRONG_PROV && !memcmp(pbData, rc2_40_salt_strong, dwDataLen)) ||
|
(STRONG_PROV && !memcmp(pbData, rc2_40_salt_strong, dwDataLen)) ||
|
||||||
(BASE_PROV && !memcmp(pbData, rc2_40_salt_base, dwDataLen)),
|
(BASE_PROV && !memcmp(pbData, rc2_40_salt_base, dwDataLen)),
|
||||||
"RC2 encryption failed!\n");
|
"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 */
|
else /* <= XP */
|
||||||
{
|
{
|
||||||
@ -1640,7 +1628,6 @@ static void test_rc2(void)
|
|||||||
if (!ENHANCED_PROV)
|
if (!ENHANCED_PROV)
|
||||||
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
|
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
|
||||||
else
|
else
|
||||||
todo_wine
|
|
||||||
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
|
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
|
||||||
|
|
||||||
result = CryptDestroyKey(hKey);
|
result = CryptDestroyKey(hKey);
|
||||||
@ -1778,20 +1765,9 @@ static void test_rc4(void)
|
|||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
|
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwDataLen, 24);
|
||||||
ok(result, "%08x\n", GetLastError());
|
ok(result, "%08x\n", GetLastError());
|
||||||
/* Remove IF when fixed */
|
|
||||||
if (ENHANCED_PROV)
|
|
||||||
{
|
|
||||||
todo_wine
|
|
||||||
ok((ENHANCED_PROV && !memcmp(pbData, rc4_40_salt, dwDataLen)) ||
|
ok((ENHANCED_PROV && !memcmp(pbData, rc4_40_salt, dwDataLen)) ||
|
||||||
(!ENHANCED_PROV && !memcmp(pbData, rc4_40_salt_base, dwDataLen)),
|
(!ENHANCED_PROV && !memcmp(pbData, rc4_40_salt_base, dwDataLen)),
|
||||||
"RC4 encryption failed!\n");
|
"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);
|
dwLen = sizeof(DWORD);
|
||||||
dwKeyLen = 12345;
|
dwKeyLen = 12345;
|
||||||
@ -1806,7 +1782,6 @@ static void test_rc4(void)
|
|||||||
if (!ENHANCED_PROV)
|
if (!ENHANCED_PROV)
|
||||||
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
|
ok(dwLen == 11, "Expected 11, got %d\n", dwLen);
|
||||||
else
|
else
|
||||||
todo_wine
|
|
||||||
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
|
ok(dwLen == 0, "Expected 0, got %d\n", dwLen);
|
||||||
|
|
||||||
result = CryptDestroyKey(hKey);
|
result = CryptDestroyKey(hKey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user