Author: akhaldi
Date: Thu Sep 26 16:41:54 2013
New Revision: 60374
URL:
http://svn.reactos.org/svn/reactos?rev=60374&view=rev
Log:
[RSAENH_WINETEST]
* Sync with Wine 1.7.1.
CORE-7469
Modified:
trunk/rostests/winetests/rsaenh/CMakeLists.txt
trunk/rostests/winetests/rsaenh/rsaenh.c
trunk/rostests/winetests/rsaenh/testlist.c
Modified: trunk/rostests/winetests/rsaenh/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rsaenh/CMakeLis…
==============================================================================
--- trunk/rostests/winetests/rsaenh/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/winetests/rsaenh/CMakeLists.txt [iso-8859-1] Thu Sep 26 16:41:54 2013
@@ -1,10 +1,5 @@
-
-add_definitions(
- -D__ROS_LONG64__
- -D_DLL -D__USE_CRTIMP)
add_executable(rsaenh_winetest rsaenh.c testlist.c)
-target_link_libraries(rsaenh_winetest wine)
set_module_type(rsaenh_winetest win32cui)
-add_importlibs(rsaenh_winetest advapi32 msvcrt kernel32 ntdll)
+add_importlibs(rsaenh_winetest advapi32 msvcrt kernel32)
add_cd_file(TARGET rsaenh_winetest DESTINATION reactos/bin FOR all)
Modified: trunk/rostests/winetests/rsaenh/rsaenh.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rsaenh/rsaenh.c…
==============================================================================
--- trunk/rostests/winetests/rsaenh/rsaenh.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/rsaenh/rsaenh.c [iso-8859-1] Thu Sep 26 16:41:54 2013
@@ -773,7 +773,7 @@
HCRYPTKEY hKey;
BOOL result;
DWORD dwLen;
- unsigned char pbData[16];
+ unsigned char pbData[16], enc_data[16], bad_data[16];
int i;
result = derive_key(CALG_3DES_112, &hKey, 0);
@@ -800,7 +800,43 @@
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
-
+ memcpy(enc_data, pbData, cTestData[i].buflen);
+
+ result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+ if((dwLen != cTestData[i].enclen) ||
+ memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen))
+ {
+ printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
+ printBytes("got",pbData,dwLen);
+ }
+
+ /* Test bad data:
+ Decrypting a block of bad data with Final = TRUE should restore the
+ initial state of the key as well as decrypting a block of good data.
+ */
+
+ /* Changing key state by setting Final = FALSE */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+
+ /* Restoring key state by decrypting bad_data with Final = TRUE */
+ memcpy(bad_data, enc_data, cTestData[i].buflen);
+ bad_data[cTestData[i].buflen - 1] = ~bad_data[cTestData[i].buflen - 1];
+ SetLastError(0xdeadbeef);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen);
+ ok(!result, "CryptDecrypt should failed!\n");
+ ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+
+ /* Checking key state */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
@@ -821,7 +857,7 @@
HCRYPTKEY hKey;
BOOL result;
DWORD dwLen, dwMode;
- unsigned char pbData[16];
+ unsigned char pbData[16], enc_data[16], bad_data[16];
int i;
result = derive_key(CALG_DES, &hKey, 56);
@@ -856,6 +892,7 @@
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
ok(result, "%08x\n", GetLastError());
@@ -867,6 +904,41 @@
printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
printBytes("got",pbData,dwLen);
}
+
+ /* Test bad data:
+ Decrypting a block of bad data with Final = TRUE should restore the
+ initial state of the key as well as decrypting a block of good data.
+ */
+
+ /* Changing key state by setting Final = FALSE */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+
+ /* Restoring key state by decrypting bad_data with Final = TRUE */
+ memcpy(bad_data, enc_data, cTestData[i].buflen);
+ bad_data[cTestData[i].buflen - 1] = ~bad_data[cTestData[i].buflen - 1];
+ SetLastError(0xdeadbeef);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen);
+ ok(!result, "CryptDecrypt should failed!\n");
+ ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+
+ /* Checking key state */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+ if((dwLen != cTestData[i].enclen) ||
+ memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen))
+ {
+ printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
+ printBytes("got",pbData,dwLen);
+ }
}
result = CryptDestroyKey(hKey);
@@ -878,7 +950,7 @@
HCRYPTKEY hKey;
BOOL result;
DWORD dwLen;
- unsigned char pbData[16];
+ unsigned char pbData[16], enc_data[16], bad_data[16];
static const BYTE des3[16] = {
0x7b, 0xba, 0xdd, 0xa2, 0x39, 0xd3, 0x7b, 0xb3,
0xc7, 0x51, 0x81, 0x41, 0x53, 0xe8, 0xcf, 0xeb };
@@ -906,6 +978,7 @@
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ memcpy(enc_data, pbData, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
ok(result, "%08x\n", GetLastError());
@@ -917,6 +990,41 @@
printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
printBytes("got",pbData,dwLen);
}
+
+ /* Test bad data:
+ Decrypting a block of bad data with Final = TRUE should restore the
+ initial state of the key as well as decrypting a block of good data.
+ */
+
+ /* Changing key state by setting Final = FALSE */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+
+ /* Restoring key state by decrypting bad_data with Final = TRUE */
+ memcpy(bad_data, enc_data, cTestData[i].buflen);
+ bad_data[cTestData[i].buflen - 1] = ~bad_data[cTestData[i].buflen - 1];
+ SetLastError(0xdeadbeef);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen);
+ ok(!result, "CryptDecrypt should failed!\n");
+ ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+
+ /* Checking key state */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+ if((dwLen != cTestData[i].enclen) ||
+ memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen))
+ {
+ printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
+ printBytes("got",pbData,dwLen);
+ }
}
result = CryptDestroyKey(hKey);
ok(result, "%08x\n", GetLastError());
@@ -927,7 +1035,7 @@
HCRYPTKEY hKey;
BOOL result;
DWORD dwLen;
- unsigned char pbData[16];
+ unsigned char pbData[16], enc_data[16], bad_data[16];
int i;
switch (keylen)
@@ -969,7 +1077,43 @@
result = CryptEncrypt(hKey, 0, TRUE, 0, pbData, &dwLen, cTestData[i].buflen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
-
+ memcpy(enc_data, pbData, cTestData[i].buflen);
+
+ result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+ if((dwLen != cTestData[i].enclen) ||
+ memcmp(pbData,cTestData[i].decstr,cTestData[i].enclen))
+ {
+ printBytes("expected",cTestData[i].decstr,cTestData[i].strlen);
+ printBytes("got",pbData,dwLen);
+ }
+
+ /* Test bad data:
+ Decrypting a block of bad data with Final = TRUE should restore the
+ initial state of the key as well as decrypting a block of good data.
+ */
+
+ /* Changing key state by setting Final = FALSE */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
+ result = CryptDecrypt(hKey, 0, FALSE, 0, pbData, &dwLen);
+ ok(result, "%08x\n", GetLastError());
+
+ /* Restoring key state by decrypting bad_data with Final = TRUE */
+ memcpy(bad_data, enc_data, cTestData[i].buflen);
+ bad_data[cTestData[i].buflen - 1] = ~bad_data[cTestData[i].buflen - 1];
+ SetLastError(0xdeadbeef);
+ result = CryptDecrypt(hKey, 0, TRUE, 0, bad_data, &dwLen);
+ ok(!result, "CryptDecrypt should failed!\n");
+ ok(GetLastError() == NTE_BAD_DATA, "%08x\n", GetLastError());
+ ok(dwLen==cTestData[i].buflen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].buflen);
+ ok(memcmp(pbData,cTestData[i].decstr,cTestData[1].enclen)==0,"decryption
incorrect %d\n",i);
+
+ /* Checking key state */
+ dwLen = cTestData[i].buflen;
+ memcpy(pbData, enc_data, cTestData[i].buflen);
result = CryptDecrypt(hKey, 0, TRUE, 0, pbData, &dwLen);
ok(result, "%08x\n", GetLastError());
ok(dwLen==cTestData[i].enclen,"length incorrect, got %d, expected
%d\n",dwLen,cTestData[i].enclen);
Modified: trunk/rostests/winetests/rsaenh/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rsaenh/testlist…
==============================================================================
--- trunk/rostests/winetests/rsaenh/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/rsaenh/testlist.c [iso-8859-1] Thu Sep 26 16:41:54 2013
@@ -1,10 +1,7 @@
/* Automatically generated file; DO NOT EDIT!! */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
#define STANDALONE
-#include "wine/test.h"
+#include <wine/test.h>
extern void func_rsaenh(void);