bcrypt/tests: Don't load bcrypt dynamically.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-01-13 10:43:36 +01:00 committed by Alexandre Julliard
parent 2cd8d27373
commit 7897c5a60f
5 changed files with 14 additions and 47 deletions

2
configure vendored
View File

@ -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_test dlls/avifil32/tests avifil32_test
wine_fn_config_dll avifile.dll16 enable_win16 wine_fn_config_dll avifile.dll16 enable_win16
wine_fn_config_dll avrt enable_avrt implib 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_test dlls/bcrypt/tests bcrypt_test
wine_fn_config_dll bluetoothapis enable_bluetoothapis wine_fn_config_dll bluetoothapis enable_bluetoothapis
wine_fn_config_dll browseui enable_browseui clean,po wine_fn_config_dll browseui enable_browseui clean,po

View File

@ -2723,7 +2723,7 @@ WINE_CONFIG_DLL(avifil32,,[clean,implib,po])
WINE_CONFIG_TEST(dlls/avifil32/tests) WINE_CONFIG_TEST(dlls/avifil32/tests)
WINE_CONFIG_DLL(avifile.dll16,enable_win16) WINE_CONFIG_DLL(avifile.dll16,enable_win16)
WINE_CONFIG_DLL(avrt,,[implib]) WINE_CONFIG_DLL(avrt,,[implib])
WINE_CONFIG_DLL(bcrypt) WINE_CONFIG_DLL(bcrypt,,[implib])
WINE_CONFIG_TEST(dlls/bcrypt/tests) WINE_CONFIG_TEST(dlls/bcrypt/tests)
WINE_CONFIG_DLL(bluetoothapis) WINE_CONFIG_DLL(bluetoothapis)
WINE_CONFIG_DLL(browseui,,[clean,po]) WINE_CONFIG_DLL(browseui,,[clean,po])

View File

@ -1,5 +1,6 @@
MODULE = bcrypt.dll MODULE = bcrypt.dll
IMPORTS = advapi32 IMPORTS = advapi32
IMPORTLIB = bcrypt
EXTRAINCL = $(GNUTLS_CFLAGS) EXTRAINCL = $(GNUTLS_CFLAGS)
C_SRCS = \ C_SRCS = \

View File

@ -1,5 +1,5 @@
TESTDLL = bcrypt.dll TESTDLL = bcrypt.dll
IMPORTS = user32 IMPORTS = bcrypt user32
C_SRCS = \ C_SRCS = \
bcrypt.c bcrypt.c

View File

@ -25,57 +25,32 @@
#include "wine/test.h" #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) static void test_BCryptGenRandom(void)
{ {
NTSTATUS ret; NTSTATUS ret;
UCHAR buffer[256]; UCHAR buffer[256];
if (!pBCryptGenRandom) ret = BCryptGenRandom(NULL, NULL, 0, 0);
{
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); 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); 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); 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); 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); BCRYPT_USE_SYSTEM_PREFERRED_RNG|BCRYPT_RNG_USE_ENTROPY_IN_BUFFER);
ok(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret); 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); ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret);
/* Zero sized buffer should work too */ /* 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); 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 */ /* Test random number generation - It's impossible for a sane RNG to return 8 zeros */
memset(buffer, 0, 16); 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(ret == STATUS_SUCCESS, "Expected success, got 0x%x\n", ret);
ok(memcmp(buffer, buffer + 8, 8), "Expected a random number, got 0\n"); ok(memcmp(buffer, buffer + 8, 8), "Expected a random number, got 0\n");
} }
@ -85,24 +60,15 @@ static void test_BCryptGetFipsAlgorithmMode(void)
NTSTATUS ret; NTSTATUS ret;
BOOLEAN enabled; BOOLEAN enabled;
if (!pBCryptGetFipsAlgorithmMode) ret = BCryptGetFipsAlgorithmMode(&enabled);
{
win_skip("BCryptGetFipsAlgorithmMode is not available\n");
return;
}
ret = pBCryptGetFipsAlgorithmMode(&enabled);
ok(ret == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got 0x%x\n", ret); 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); ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret);
} }
START_TEST(bcrypt) START_TEST(bcrypt)
{ {
if (!Init())
return;
test_BCryptGenRandom(); test_BCryptGenRandom();
test_BCryptGetFipsAlgorithmMode(); test_BCryptGetFipsAlgorithmMode();
} }