[4/4] rsaenh: CALG_AES cannot be used if the key length was not specified
Bruno Jesus
00cpxxx at gmail.com
Tue Jul 22 22:48:51 CDT 2014
-------------- next part --------------
---
dlls/rsaenh/rsaenh.c | 10 +++++++++-
dlls/rsaenh/tests/rsaenh.c | 17 -----------------
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c
index aec203c..892e6f4 100644
--- a/dlls/rsaenh/rsaenh.c
+++ b/dlls/rsaenh/rsaenh.c
@@ -780,7 +780,7 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
{
HCRYPTKEY hCryptKey;
CRYPTKEY *pCryptKey;
- DWORD dwKeyLen = HIWORD(dwFlags);
+ DWORD dwKeyLen = HIWORD(dwFlags), bKeyLen = dwKeyLen;
const PROV_ENUMALGS_EX *peaAlgidInfo;
*ppCryptKey = NULL;
@@ -839,6 +839,14 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
*/
break;
+ case CALG_AES:
+ if (!bKeyLen)
+ {
+ TRACE("missing key len for CALG_AES\n");
+ SetLastError(NTE_BAD_ALGID);
+ return (HCRYPTKEY)INVALID_HANDLE_VALUE;
+ }
+ /* fall through */
default:
if (dwKeyLen % 8 ||
dwKeyLen > peaAlgidInfo->dwMaxLen ||
diff --git a/dlls/rsaenh/tests/rsaenh.c b/dlls/rsaenh/tests/rsaenh.c
index c49bd92..7106c80 100644
--- a/dlls/rsaenh/tests/rsaenh.c
+++ b/dlls/rsaenh/tests/rsaenh.c
@@ -3511,13 +3511,6 @@ static void test_key_derivation(const char *prov)
/* 47 */
},
};
-
- /* Temporary struct to hold wine broken cases */
- struct broken
- {
- int mode, exp_data, blen;
- } wine_broken[sizeof(tests)/sizeof(tests[0])];
-
/* Due to differences between encryption from <= 2000 and >= XP some tests need to be skipped */
int old_broken[sizeof(tests)/sizeof(tests[0])];
memset(old_broken, 0, sizeof(old_broken));
@@ -3525,10 +3518,6 @@ static void test_key_derivation(const char *prov)
old_broken[27] = old_broken[28] = old_broken[39] = old_broken[40] = 1;
uniquecontainer(NULL);
- memset(wine_broken, 0, sizeof(wine_broken));
- wine_broken[8].mode = wine_broken[8].blen = 1;
- wine_broken[20] = wine_broken[32] = wine_broken[44] = wine_broken[8];
-
for (i=0; i<sizeof(tests)/sizeof(tests[0]); i++)
{
if (win2k && old_broken[i]) continue;
@@ -3567,23 +3556,17 @@ static void test_key_derivation(const char *prov)
mode = 0xdeadbeef;
result = CryptGetKeyParam(hKey, KP_MODE, (BYTE*)&mode, &len, 0);
ok(result, "Test [%s %d]: CryptGetKeyParam failed with error %08x\n", prov, i, GetLastError());
- if (wine_broken[i].mode) winetest_start_todo("wine");
ok(mode == tests[i].chain_mode, "Test [%s %d]: Expected chaining mode %d, got %d\n",
prov, i, tests[i].chain_mode, mode);
- if (wine_broken[i].mode) winetest_end_todo("wine");
SetLastError(0xdeadbeef);
len = 4;
result = CryptEncrypt(hKey, 0, TRUE, 0, dvData, &len, sizeof(dvData));
ok(result, "Test [%s %d]: CryptEncrypt failed with error 0x%08x\n", prov, i, GetLastError());
- if (wine_broken[i].blen) winetest_start_todo("wine");
ok(len == tests[i].blocklen, "Test [%s %d]: Expected block len %d, got %d\n",
prov, i, tests[i].blocklen, len);
- if (wine_broken[i].blen) winetest_end_todo("wine");
- if (wine_broken[i].exp_data) winetest_start_todo("wine");
ok(!memcmp(dvData, tests[i].expected_enc, tests[i].blocklen),
"Test [%s %d]: Encrypted data comparison failed\n", prov, i);
- if (wine_broken[i].exp_data) winetest_end_todo("wine");
CryptDestroyKey(hKey);
err:
--
1.8.3.2
More information about the wine-patches
mailing list