Commit b402b787 authored by Alexandre Julliard's avatar Alexandre Julliard

rsaenh: Fix padding bytes check for 0-byte payload.

parent b5ca0a9c
...@@ -213,7 +213,7 @@ static void test_cryptunprotectdata(void) ...@@ -213,7 +213,7 @@ static void test_cryptunprotectdata(void)
plain.cbData=0; plain.cbData=0;
} }
static void test_simpleroundtrip(const char *plaintext, int wine_fails) static void test_simpleroundtrip(const char *plaintext)
{ {
DATA_BLOB input; DATA_BLOB input;
DATA_BLOB encrypted; DATA_BLOB encrypted;
...@@ -234,17 +234,9 @@ static void test_simpleroundtrip(const char *plaintext, int wine_fails) ...@@ -234,17 +234,9 @@ static void test_simpleroundtrip(const char *plaintext, int wine_fails)
} }
res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output); res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output);
if (wine_fails) { ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
todo_wine ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, strlen(plaintext));
ok(res != 0, "can't unprotect; last error %u\n", GetLastError()); ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext);
} else {
ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
}
if (res) {
ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, strlen(plaintext));
ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext);
}
} }
START_TEST(protectdata) START_TEST(protectdata)
...@@ -262,8 +254,8 @@ START_TEST(protectdata) ...@@ -262,8 +254,8 @@ START_TEST(protectdata)
protected=FALSE; protected=FALSE;
test_cryptprotectdata(); test_cryptprotectdata();
test_cryptunprotectdata(); test_cryptunprotectdata();
test_simpleroundtrip("", 1); test_simpleroundtrip("");
test_simpleroundtrip("hello", 0); test_simpleroundtrip("hello");
/* deinit globals here */ /* deinit globals here */
if (cipher.pbData) LocalFree(cipher.pbData); if (cipher.pbData) LocalFree(cipher.pbData);
......
...@@ -2324,7 +2324,7 @@ BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, ...@@ -2324,7 +2324,7 @@ BOOL WINAPI RSAENH_CPDecrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash,
if (Final) { if (Final) {
if (pbData[*pdwDataLen-1] && if (pbData[*pdwDataLen-1] &&
pbData[*pdwDataLen-1] <= pCryptKey->dwBlockLen && pbData[*pdwDataLen-1] <= pCryptKey->dwBlockLen &&
pbData[*pdwDataLen-1] < *pdwDataLen) { pbData[*pdwDataLen-1] <= *pdwDataLen) {
BOOL padOkay = TRUE; BOOL padOkay = TRUE;
/* check that every bad byte has the same value */ /* check that every bad byte has the same value */
......
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