d3d8/tests: Use a separate device for alpha_test().
[wine.git] / dlls / bcrypt / bcrypt_main.c
blob22da0dd30d16a6507fc6ca9f49cb9aa37529e9e7
1 /*
2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
22 #include <stdarg.h>
24 #include "ntstatus.h"
25 #define WIN32_NO_STATUS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ntsecapi.h"
29 #include "bcrypt.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
34 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
36 TRACE("fdwReason %u\n", fdwReason);
38 switch(fdwReason)
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(hInstDLL);
42 break;
45 return TRUE;
48 NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
49 BCRYPT_ALGORITHM_IDENTIFIER **ppAlgList, ULONG dwFlags)
51 FIXME("%08x, %p, %p, %08x - stub\n", dwAlgOperations, pAlgCount, ppAlgList, dwFlags);
53 *ppAlgList=NULL;
54 *pAlgCount=0;
56 return STATUS_NOT_IMPLEMENTED;
59 NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE algorithm, UCHAR *buffer, ULONG count, ULONG flags)
61 const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG;
62 TRACE("%p, %p, %u, %08x - semi-stub\n", algorithm, buffer, count, flags);
64 if (!algorithm)
66 /* It's valid to call without an algorithm if BCRYPT_USE_SYSTEM_PREFERRED_RNG
67 * is set. In this case the preferred system RNG is used.
69 if (!(flags & BCRYPT_USE_SYSTEM_PREFERRED_RNG))
70 return STATUS_INVALID_HANDLE;
72 if (!buffer)
73 return STATUS_INVALID_PARAMETER;
75 if (flags & ~supported_flags)
76 FIXME("unsupported flags %08x\n", flags & ~supported_flags);
78 if (algorithm)
79 FIXME("ignoring selected algorithm\n");
81 /* When zero bytes are requested the function returns success too. */
82 if (!count)
83 return STATUS_SUCCESS;
85 if (flags & BCRYPT_USE_SYSTEM_PREFERRED_RNG)
87 if (RtlGenRandom(buffer, count))
88 return STATUS_SUCCESS;
91 FIXME("called with unsupported parameters, returning error\n");
92 return STATUS_NOT_IMPLEMENTED;