bcrypt/tests: Add tests for BCryptGenRandom.
This commit is contained in:
parent
52aca431e4
commit
a5807d08c5
|
@ -16653,6 +16653,7 @@ 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_test dlls/bcrypt/tests bcrypt_test
|
||||
wine_fn_config_dll browseui enable_browseui clean,po
|
||||
wine_fn_config_test dlls/browseui/tests browseui_test
|
||||
wine_fn_config_dll cabinet enable_cabinet implib
|
||||
|
|
|
@ -2678,6 +2678,7 @@ WINE_CONFIG_TEST(dlls/avifil32/tests)
|
|||
WINE_CONFIG_DLL(avifile.dll16,enable_win16)
|
||||
WINE_CONFIG_DLL(avrt,,[implib])
|
||||
WINE_CONFIG_DLL(bcrypt)
|
||||
WINE_CONFIG_TEST(dlls/bcrypt/tests)
|
||||
WINE_CONFIG_DLL(browseui,,[clean,po])
|
||||
WINE_CONFIG_TEST(dlls/browseui/tests)
|
||||
WINE_CONFIG_DLL(cabinet,,[implib])
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
TESTDLL = bcrypt.dll
|
||||
IMPORTS = user32
|
||||
|
||||
C_SRCS = \
|
||||
bcrypt.c
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
todo_wine {
|
||||
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, NULL, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
ok(ret == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got 0x%x\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(bcrypt)
|
||||
{
|
||||
if (!Init())
|
||||
return;
|
||||
|
||||
test_BCryptGenRandom();
|
||||
}
|
Loading…
Reference in New Issue