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
25 #define WIN32_NO_STATUS
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
);
40 case DLL_PROCESS_ATTACH
:
41 DisableThreadLibraryCalls(hInstDLL
);
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
);
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
);
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
;
73 return STATUS_INVALID_PARAMETER
;
75 if (flags
& ~supported_flags
)
76 FIXME("unsupported flags %08x\n", flags
& ~supported_flags
);
79 FIXME("ignoring selected algorithm\n");
81 /* When zero bytes are requested the function returns success too. */
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
;