Module: wine Branch: master Commit: a5807d08c57e60e600f746a1d057db8688a39290 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a5807d08c57e60e600f746a1d0...
Author: Bruno Jesus 00cpxxx@gmail.com Date: Mon Feb 3 16:24:48 2014 -0200
bcrypt/tests: Add tests for BCryptGenRandom.
---
configure | 1 + configure.ac | 1 + dlls/bcrypt/tests/Makefile.in | 5 +++ dlls/bcrypt/tests/bcrypt.c | 76 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+)
diff --git a/configure b/configure index 4e999a9..8c3e28e 100755 --- a/configure +++ b/configure @@ -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 diff --git a/configure.ac b/configure.ac index 7f3c35b..c6769fc 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/dlls/bcrypt/tests/Makefile.in b/dlls/bcrypt/tests/Makefile.in new file mode 100644 index 0000000..b193519 --- /dev/null +++ b/dlls/bcrypt/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = bcrypt.dll +IMPORTS = user32 + +C_SRCS = \ + bcrypt.c diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c new file mode 100644 index 0000000..1d18634 --- /dev/null +++ b/dlls/bcrypt/tests/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(); +}