From be03b064bffafbd378c0d5cc5971594573544d64 Mon Sep 17 00:00:00 2001 From: miod <> Date: Tue, 15 Apr 2014 16:52:50 +0000 Subject: Replace the old OpenSSL PRNG by direct use of arc4random_buf(), keeping the existing RAND interfaces unchanged. All interfaces allowing external feed or seed of the RNG (either from a file or a local entropy gathering daemon) are kept for ABI compatibility, but are no longer do anything. While the OpenSSL PRNG was required 15+ years ago when many systems lacked proper entropy collection, things have evolved and one can reasonably assume it is better to use the kernel (system global) entropy pool rather than trying to build one's own and having to compensate for thread scheduling... Whoever thought that RAND_screen(), feeding the PRNG with the contents of the local workstation's display, under Win32, was a smart idea, ought to be banned from security programming. ok beck@ deraadt@ tedu@ --- src/lib/libcrypto/doc/RAND_add.pod | 57 +++----------------------------- src/lib/libcrypto/doc/RAND_load_file.pod | 14 ++++---- 2 files changed, 12 insertions(+), 59 deletions(-) (limited to 'src/lib/libcrypto/doc') diff --git a/src/lib/libcrypto/doc/RAND_add.pod b/src/lib/libcrypto/doc/RAND_add.pod index 67c66f3e0c..d55dc125d3 100644 --- a/src/lib/libcrypto/doc/RAND_add.pod +++ b/src/lib/libcrypto/doc/RAND_add.pod @@ -2,8 +2,7 @@ =head1 NAME -RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add -entropy to the PRNG +RAND_add, RAND_seed, RAND_status - add entropy to the PRNG (DEPRECATED) =head1 SYNOPSIS @@ -15,63 +14,17 @@ entropy to the PRNG int RAND_status(void); - int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam); - void RAND_screen(void); - =head1 DESCRIPTION -RAND_add() mixes the B bytes at B into the PRNG state. Thus, -if the data at B are unpredictable to an adversary, this -increases the uncertainty about the state and makes the PRNG output -less predictable. Suitable input comes from user interaction (random -key presses, mouse movements) and certain hardware events. The -B argument is (the lower bound of) an estimate of how much -randomness is contained in B, measured in bytes. Details about -sources of randomness and how to estimate their entropy can be found -in the literature, e.g. RFC 1750. - -RAND_add() may be called with sensitive data such as user entered -passwords. The seed values cannot be recovered from the PRNG output. - -OpenSSL makes sure that the PRNG state is unique for each thread. On -systems that provide C, the randomness device is used -to seed the PRNG transparently. However, on all other systems, the -application is responsible for seeding the PRNG by calling RAND_add(), -L -or L. - -RAND_seed() is equivalent to RAND_add() when B. - -RAND_event() collects the entropy from Windows events such as mouse -movements and other user interaction. It should be called with the -B, B and B arguments of I messages sent to -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. +These functions used to allow for the state of the random number generator +to be controlled by external sources. -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 -with enough data, 0 otherwise. - -The other functions do not return values. +They are kept for ABI compatibility but are no longer functional, and +should not used in new programs. =head1 SEE ALSO L, L, L, L -=head1 HISTORY - -RAND_seed() and RAND_screen() are available in all versions of SSLeay -and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL -0.9.5, RAND_event() in OpenSSL 0.9.5a. - =cut diff --git a/src/lib/libcrypto/doc/RAND_load_file.pod b/src/lib/libcrypto/doc/RAND_load_file.pod index d8c134e621..3f7e944d86 100644 --- a/src/lib/libcrypto/doc/RAND_load_file.pod +++ b/src/lib/libcrypto/doc/RAND_load_file.pod @@ -22,18 +22,18 @@ filename. The seed file is $RANDFILE if that environment variable is set, $HOME/.rnd otherwise. If $HOME is not set either, or B is too small for the path name, an error occurs. -RAND_load_file() reads a number of bytes from file B and -adds them to the PRNG. If B is non-negative, -up to to B are read; starting with OpenSSL 0.9.5, -if B is -1, the complete file is read. +RAND_load_file() used to allow for the state of the random number generator +to be controlled by external sources. + +It is kept for ABI compatibility but is no longer functional, and +should not used in new programs. RAND_write_file() writes a number of random bytes (currently 1024) to -file B which can be used to initialize the PRNG by calling -RAND_load_file() in a later session. +file B. =head1 RETURN VALUES -RAND_load_file() returns the number of bytes read. +RAND_load_file() always returns 0. RAND_write_file() returns the number of bytes written, and -1 if the bytes written were generated without appropriate seed. -- cgit v1.2.3-55-g6feb