提交 888db7f2 编写于 作者: J Joey Yandle 提交者: Rich Salz

cherry pick pr-512 changes

Reviewed-by: NMatt Caswell <matt@openssl.org>
Reviewed-by: NTim Hudson <tjh@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1079)
上级 4447d829
......@@ -19,10 +19,6 @@ int app_RAND_load_file(const char *file, int dont_warn)
int consider_randfile = (file == NULL);
char buffer[200];
#ifdef OPENSSL_SYS_WINDOWS
RAND_screen();
#endif
if (file == NULL)
file = RAND_file_name(buffer, sizeof buffer);
#ifndef OPENSSL_NO_EGD
......
......@@ -34,7 +34,6 @@
# define INTEL_DEF_PROV L"Intel Hardware Cryptographic Service Provider"
static void readtimer(void);
static void readscreen(void);
/*
* It appears like CURSORINFO, PCURSORINFO and LPCURSORINFO are only defined
......@@ -135,13 +134,6 @@ int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
return (RAND_status());
}
void RAND_screen(void)
{ /* function available for backward
* compatibility */
RAND_poll();
readscreen();
}
/* feed timing information to the PRNG */
static void readtimer(void)
{
......@@ -179,91 +171,4 @@ static void readtimer(void)
}
}
/* feed screen contents to PRNG */
/*****************************************************************************
*
* Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V.
*
* Code adapted from
* <URL:http://support.microsoft.com/default.aspx?scid=kb;[LN];97193>;
* the original copyright message is:
*
* (C) Copyright Microsoft Corp. 1993. All rights reserved.
*
* You have a royalty-free right to use, modify, reproduce and
* distribute the Sample Files (and/or any modified version) in
* any way you find useful, provided that you agree that
* Microsoft has no warranty obligations or liability for any
* Sample Application Files which are modified.
*/
static void readscreen(void)
{
# if !defined(OPENSSL_SYS_WIN32_CYGWIN)
HDC hScrDC; /* screen DC */
HBITMAP hBitmap; /* handle for our bitmap */
BITMAP bm; /* bitmap properties */
unsigned int size; /* size of bitmap */
char *bmbits; /* contents of bitmap */
int w; /* screen width */
int h; /* screen height */
int y; /* y-coordinate of screen lines to grab */
int n = 16; /* number of screen lines to grab at a time */
BITMAPINFOHEADER bi; /* info about the bitmap */
if (check_winnt() && OPENSSL_isservice() > 0)
return;
/* Get a reference to the screen DC */
hScrDC = GetDC(NULL);
/* Get screen resolution */
w = GetDeviceCaps(hScrDC, HORZRES);
h = GetDeviceCaps(hScrDC, VERTRES);
/* Create a bitmap compatible with the screen DC */
hBitmap = CreateCompatibleBitmap(hScrDC, w, n);
/* Get bitmap properties */
GetObject(hBitmap, sizeof(BITMAP), (LPSTR) & bm);
size = (unsigned int)bm.bmWidthBytes * bm.bmHeight * bm.bmPlanes;
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = bm.bmWidth;
bi.biHeight = bm.bmHeight;
bi.biPlanes = bm.bmPlanes;
bi.biBitCount = bm.bmBitsPixel;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
bmbits = OPENSSL_malloc(size);
if (bmbits != NULL) {
/* Now go through the whole screen, repeatedly grabbing n lines */
for (y = 0; y < h - n; y += n) {
unsigned char md[MD_DIGEST_LENGTH];
/* Copy the bits of the current line range into the buffer */
GetDIBits(hScrDC, hBitmap, y, n,
bmbits, (BITMAPINFO *) & bi, DIB_RGB_COLORS);
/* Get the hash of the bitmap */
MD(bmbits, size, md);
/* Seed the random generator with the hash value */
RAND_add(md, MD_DIGEST_LENGTH, 0);
}
OPENSSL_free(bmbits);
}
/* Clean up */
DeleteObject(hBitmap);
ReleaseDC(NULL, hScrDC);
# endif /* !OPENSSL_SYS_WIN32_CYGWIN */
}
#endif
......@@ -2,7 +2,7 @@
=head1 NAME
RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add
RAND_add, RAND_seed, RAND_status, RAND_event - add
entropy to the PRNG
=head1 SYNOPSIS
......@@ -16,7 +16,6 @@ entropy to the PRNG
int RAND_status(void);
int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
void RAND_screen(void);
=head1 DESCRIPTION
......@@ -49,13 +48,6 @@ the window procedure. It will estimate the entropy contained in the
event message (if any), and add it to the PRNG. The program can then
process the messages as usual.
The RAND_screen() function is available for the convenience of Windows
programmers. It adds the current contents of the screen to the PRNG.
For applications that can catch Windows events, seeding the PRNG by
calling RAND_event() is a significantly better source of
randomness. It should be noted that both methods cannot be used on
servers that run without user interaction.
=head1 RETURN VALUES
RAND_status() and RAND_event() return 1 if the PRNG has been seeded
......
......@@ -28,7 +28,6 @@ rand - pseudo-random number generator
RAND_METHOD *RAND_OpenSSL(void);
/* For Win32 only */
void RAND_screen(void);
int RAND_event(UINT, WPARAM, LPARAM);
Deprecated:
......
......@@ -67,7 +67,6 @@ int RAND_poll(void);
# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
void RAND_screen(void);
int RAND_event(UINT, WPARAM, LPARAM);
# endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册