# Winsock.
if(WIN32)
- set(CMAKE_REQUIRED_LIBRARIES ws2_32 shell32 advapi32)
+ set(CMAKE_REQUIRED_LIBRARIES ws2_32 shell32 advapi32 bcrypt)
set(CMAKE_REQUIRED_DEFINITIONS -FIwinsock2.h -FIws2tcpip.h -D_WIN32_WINNT=0x0600)
endif()
if (SOLARIS)
list(APPEND HDR_PRIVATE WIN32-Code/getopt.h)
set(EVENT__DNS_USE_FTIME_FOR_ID 1)
- set(LIB_PLATFORM ws2_32 shell32 advapi32)
+ set(LIB_PLATFORM ws2_32 shell32 advapi32 bcrypt)
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
-D_CRT_NONSTDC_NO_DEPRECATE)
if BUILD_WIN32
SYS_CORE_LIBS = -liphlpapi
-SYS_LIBS = -lws2_32 -lshell32 -ladvapi32
+SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 -lbcrypt
SYS_SRC = win32select.c buffer_iocp.c event_iocp.c \
bufferevent_async.c
SYS_INCLUDES = -IWIN32-Code
#ifndef ARC4RANDOM_NO_INCLUDES
#include "evconfig-private.h"
#ifdef _WIN32
-#include <wincrypt.h>
+#include <bcrypt.h>
#include <process.h>
#include <winerror.h>
#else
static int
arc4_seed_win32(void)
{
- /* This is adapted from Tor's crypto_seed_rng() */
- static int provider_set = 0;
- static HCRYPTPROV provider;
unsigned char buf[ADD_ENTROPY];
- if (!provider_set) {
- if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT)) {
- if (GetLastError() != (DWORD)NTE_BAD_KEYSET)
- return -1;
- }
- provider_set = 1;
- }
- if (!CryptGenRandom(provider, sizeof(buf), buf))
+ if (BCryptGenRandom(NULL, buf, sizeof(buf),
+ BCRYPT_USE_SYSTEM_PREFERRED_RNG))
return -1;
arc4_addrandom(buf, sizeof(buf));
evutil_memclear_(buf, sizeof(buf));
*
* Current versions of Libevent use an ARC4-based random number generator,
* seeded using the platform's entropy source (/dev/urandom on Unix-like
- * systems; CryptGenRandom on Windows). This is not actually as secure as it
+ * systems; BCryptGenRandom on Windows). This is not actually as secure as it
* should be: ARC4 is a pretty lousy cipher, and the current implementation
* provides only rudimentary prediction- and backtracking-resistance. Don't
* use this for serious cryptographic applications.