Hans Leidekker : bcrypt/tests: Don't load bcrypt dynamically.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 13 12:14:17 CST 2016


Module: wine
Branch: master
Commit: 7897c5a60f06f73672a6a24e8c0da99883c90b28
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7897c5a60f06f73672a6a24e8c0da99883c90b28

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Jan 13 10:43:36 2016 +0100

bcrypt/tests: Don't load bcrypt dynamically.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure                     |  2 +-
 configure.ac                  |  2 +-
 dlls/bcrypt/Makefile.in       |  1 +
 dlls/bcrypt/tests/Makefile.in |  2 +-
 dlls/bcrypt/tests/bcrypt.c    | 54 ++++++++-----------------------------------
 5 files changed, 14 insertions(+), 47 deletions(-)

diff --git a/configure b/configure
index 339a734..66dca2b 100755
--- a/configure
+++ b/configure
@@ -17379,7 +17379,7 @@ wine_fn_config_dll avifil32 enable_avifil32 clean,implib,po
 wine_fn_config_test dlls/avifil32/tests avifil32_test
 wine_fn_config_dll avifile.dll16 enable_win16
 wine_fn_config_dll avrt enable_avrt implib
-wine_fn_config_dll bcrypt enable_bcrypt
+wine_fn_config_dll bcrypt enable_bcrypt implib
 wine_fn_config_test dlls/bcrypt/tests bcrypt_test
 wine_fn_config_dll bluetoothapis enable_bluetoothapis
 wine_fn_config_dll browseui enable_browseui clean,po
diff --git a/configure.ac b/configure.ac
index 3712906..811e2aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2723,7 +2723,7 @@ WINE_CONFIG_DLL(avifil32,,[clean,implib,po])
 WINE_CONFIG_TEST(dlls/avifil32/tests)
 WINE_CONFIG_DLL(avifile.dll16,enable_win16)
 WINE_CONFIG_DLL(avrt,,[implib])
-WINE_CONFIG_DLL(bcrypt)
+WINE_CONFIG_DLL(bcrypt,,[implib])
 WINE_CONFIG_TEST(dlls/bcrypt/tests)
 WINE_CONFIG_DLL(bluetoothapis)
 WINE_CONFIG_DLL(browseui,,[clean,po])
diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
index 54814a0..ef9d7ea 100644
--- a/dlls/bcrypt/Makefile.in
+++ b/dlls/bcrypt/Makefile.in
@@ -1,5 +1,6 @@
 MODULE    = bcrypt.dll
 IMPORTS   = advapi32
+IMPORTLIB = bcrypt
 EXTRAINCL = $(GNUTLS_CFLAGS)
 
 C_SRCS = \
diff --git a/dlls/bcrypt/tests/Makefile.in b/dlls/bcrypt/tests/Makefile.in
index b193519..0f130b1 100644
--- a/dlls/bcrypt/tests/Makefile.in
+++ b/dlls/bcrypt/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL  = bcrypt.dll
-IMPORTS  = user32
+IMPORTS  = bcrypt user32
 
 C_SRCS = \
 	bcrypt.c
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 9e659d6..ad54ab2 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -25,57 +25,32 @@
 
 #include "wine/test.h"
 
-static NTSTATUS (WINAPI *pBCryptGenRandom)(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer,
-                                           ULONG cbBuffer, ULONG dwFlags);
-static NTSTATUS (WINAPI *pBCryptGetFipsAlgorithmMode)(BOOLEAN *enabled);
-
-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");
-    pBCryptGetFipsAlgorithmMode = (void *)GetProcAddress(hbcrypt, "BCryptGetFipsAlgorithmMode");
-
-    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);
+    ret = BCryptGenRandom(NULL, NULL, 0, 0);
     ok(ret == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got 0x%x\n", ret);
-    ret = pBCryptGenRandom(NULL, buffer, 0, 0);
+    ret = BCryptGenRandom(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);
+    ret = BCryptGenRandom(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);
+    ret = BCryptGenRandom(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),
+    ret = BCryptGenRandom(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);
+    ret = BCryptGenRandom(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);
+    ret = BCryptGenRandom(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);
+    ret = BCryptGenRandom(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");
 }
@@ -85,24 +60,15 @@ static void test_BCryptGetFipsAlgorithmMode(void)
     NTSTATUS ret;
     BOOLEAN enabled;
 
-    if (!pBCryptGetFipsAlgorithmMode)
-    {
-        win_skip("BCryptGetFipsAlgorithmMode is not available\n");
-        return;
-    }
-
-    ret = pBCryptGetFipsAlgorithmMode(&enabled);
+    ret = BCryptGetFipsAlgorithmMode(&enabled);
     ok(ret == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%x\n", ret);
 
-    ret = pBCryptGetFipsAlgorithmMode(NULL);
+    ret = BCryptGetFipsAlgorithmMode(NULL);
     ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret);
 }
 
 START_TEST(bcrypt)
 {
-    if (!Init())
-        return;
-
     test_BCryptGenRandom();
     test_BCryptGetFipsAlgorithmMode();
 }




More information about the wine-cvs mailing list