From: Mat Date: Sun, 29 May 2016 18:38:37 +0000 (+0200) Subject: Define USE_BCRYPT X-Git-Tag: OpenSSL_1_1_0-pre6~576 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=0814afcfa46039c8f27739dbe6a355b731f34608;hp=fa64e63373fbc845a39907407ad990a6bbb84174;ds=sidebyside Define USE_BCRYPT Define USE_BCRYPT Removed _WIN32_WINNT define Reviewed-by: Matt Caswell Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1142) --- diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c index 2ddac8a0f8..21cc9b6bcb 100644 --- a/crypto/rand/rand_win.c +++ b/crypto/rand/rand_win.c @@ -13,13 +13,15 @@ #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) # include +/* On Windows 7 or higher use BCrypt instead of the legacy CryptoAPI */ # if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601 +# define USE_BCRYPT 1 +# endif + +# ifdef USE_BCRYPT # include # pragma comment(lib, "bcrypt.lib") # else -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0400 -# endif # include /* * Intel hardware RNG CSP -- available from @@ -34,13 +36,13 @@ static void readtimer(void); int RAND_poll(void) { MEMORYSTATUS mst; -# if !(defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601) +# ifndef USE_BCRYPT HCRYPTPROV hProvider = 0; # endif DWORD w; BYTE buf[64]; -# if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0601 +# ifdef USE_BCRYPT if (BCryptGenRandom(NULL, buf, (ULONG)sizeof(buf), BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0) { RAND_add(buf, sizeof(buf), sizeof(buf)); }