Author: akhaldi
Date: Tue Apr 22 11:36:32 2014
New Revision: 62873
URL:
http://svn.reactos.org/svn/reactos?rev=62873&view=rev
Log:
[BCRYPT_WINETEST]
* Import from Wine 1.7.17.
CORE-8080
Added:
trunk/rostests/winetests/bcrypt/ (with props)
trunk/rostests/winetests/bcrypt/CMakeLists.txt (with props)
trunk/rostests/winetests/bcrypt/bcrypt.c (with props)
trunk/rostests/winetests/bcrypt/testlist.c (with props)
Modified:
trunk/rostests/winetests/CMakeLists.txt
Modified: trunk/rostests/winetests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/CMakeLists.txt?…
==============================================================================
--- trunk/rostests/winetests/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/winetests/CMakeLists.txt [iso-8859-1] Tue Apr 22 11:36:32 2014
@@ -8,6 +8,7 @@
add_subdirectory(atl100)
add_subdirectory(atl80)
add_subdirectory(avifil32)
+add_subdirectory(bcrypt)
add_subdirectory(browseui)
add_subdirectory(cabinet)
add_subdirectory(cmd)
Propchange: trunk/rostests/winetests/bcrypt/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Apr 22 11:36:32 2014
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/rostests/winetests/bcrypt/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/rostests/winetests/bcrypt/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: trunk/rostests/winetests/bcrypt/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/bcrypt/CMakeLis…
==============================================================================
--- trunk/rostests/winetests/bcrypt/CMakeLists.txt (added)
+++ trunk/rostests/winetests/bcrypt/CMakeLists.txt [iso-8859-1] Tue Apr 22 11:36:32 2014
@@ -0,0 +1,5 @@
+
+add_executable(bcrypt_winetest bcrypt.c testlist.c)
+set_module_type(bcrypt_winetest win32cui)
+add_importlibs(bcrypt_winetest user32 msvcrt kernel32)
+add_cd_file(TARGET bcrypt_winetest DESTINATION reactos/bin FOR all)
Propchange: trunk/rostests/winetests/bcrypt/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/bcrypt/bcrypt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/bcrypt/bcrypt.c…
==============================================================================
--- trunk/rostests/winetests/bcrypt/bcrypt.c (added)
+++ trunk/rostests/winetests/bcrypt/bcrypt.c [iso-8859-1] Tue Apr 22 11:36:32 2014
@@ -0,0 +1,87 @@
+/*
+ * Unit test for bcrypt functions
+ *
+ * Copyright 2014 Bruno Jesus
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <ntstatus.h>
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <bcrypt.h>
+
+#include "wine/test.h"
+
+static NTSTATUS (WINAPI *pBCryptGenRandom)(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR
pbBuffer,
+ ULONG cbBuffer, ULONG dwFlags);
+
+static BOOL Init(void)
+{
+ HMODULE hbcrypt = LoadLibraryA("bcrypt.dll");
+ if (!hbcrypt)
+ {
+ win_skip("bcrypt library not available\n");
+ return FALSE;
+ }
+
+ pBCryptGenRandom = (void *)GetProcAddress(hbcrypt, "BCryptGenRandom");
+
+ return TRUE;
+}
+
+static void test_BCryptGenRandom(void)
+{
+ NTSTATUS ret;
+ UCHAR buffer[256];
+
+ if (!pBCryptGenRandom)
+ {
+ win_skip("BCryptGenRandom is not available\n");
+ return;
+ }
+
+ ret = pBCryptGenRandom(NULL, NULL, 0, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got
0x%x\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, 0, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got
0x%x\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, sizeof(buffer), 0);
+ ok(ret == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got
0x%x\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, sizeof(buffer),
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret);
+ ret = pBCryptGenRandom(NULL, buffer, sizeof(buffer),
+ BCRYPT_USE_SYSTEM_PREFERRED_RNG|BCRYPT_RNG_USE_ENTROPY_IN_BUFFER);
+ ok(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret);
+ ret = pBCryptGenRandom(NULL, NULL, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got
0x%x\n", ret);
+
+ /* Zero sized buffer should work too */
+ ret = pBCryptGenRandom(NULL, buffer, 0, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret);
+
+ /* Test random number generation - It's impossible for a sane RNG to return 8
zeros */
+ memset(buffer, 0, 16);
+ ret = pBCryptGenRandom(NULL, buffer, 8, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
+ ok(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret);
+ ok(memcmp(buffer, buffer + 8, 8), "Expected a random number, got 0\n");
+}
+
+START_TEST(bcrypt)
+{
+ if (!Init())
+ return;
+
+ test_BCryptGenRandom();
+}
Propchange: trunk/rostests/winetests/bcrypt/bcrypt.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/winetests/bcrypt/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/bcrypt/testlist…
==============================================================================
--- trunk/rostests/winetests/bcrypt/testlist.c (added)
+++ trunk/rostests/winetests/bcrypt/testlist.c [iso-8859-1] Tue Apr 22 11:36:32 2014
@@ -0,0 +1,12 @@
+/* Automatically generated; DO NOT EDIT!! */
+
+#define STANDALONE
+#include <wine/test.h>
+
+extern void func_bcrypt(void);
+
+const struct test winetest_testlist[] =
+{
+ { "bcrypt", func_bcrypt },
+ { 0, 0 }
+};
Propchange: trunk/rostests/winetests/bcrypt/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native