RAND_add.pod 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. =pod
  2. =head1 NAME
  3. RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add
  4. entropy to the PRNG
  5. =head1 SYNOPSIS
  6. #include <openssl/rand.h>
  7. void RAND_seed(const void *buf, int num);
  8. void RAND_add(const void *buf, int num, double entropy);
  9. int RAND_status(void);
  10. int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
  11. void RAND_screen(void);
  12. =head1 DESCRIPTION
  13. RAND_add() mixes the B<num> bytes at B<buf> into the PRNG state. Thus,
  14. if the data at B<buf> are unpredictable to an adversary, this
  15. increases the uncertainty about the state and makes the PRNG output
  16. less predictable. Suitable input comes from user interaction (random
  17. key presses, mouse movements) and certain hardware events. The
  18. B<entropy> argument is (the lower bound of) an estimate of how much
  19. randomness is contained in B<buf>, measured in bytes. Details about
  20. sources of randomness and how to estimate their entropy can be found
  21. in the literature, e.g. RFC 1750.
  22. RAND_add() may be called with sensitive data such as user entered
  23. passwords. The seed values cannot be recovered from the PRNG output.
  24. OpenSSL makes sure that the PRNG state is unique for each thread. On
  25. systems that provide C</dev/urandom>, the randomness device is used
  26. to seed the PRNG transparently. However, on all other systems, the
  27. application is responsible for seeding the PRNG by calling RAND_add(),
  28. L<RAND_egd(3)|RAND_egd(3)>
  29. or L<RAND_load_file(3)|RAND_load_file(3)>.
  30. RAND_seed() is equivalent to RAND_add() when B<num == entropy>.
  31. RAND_event() collects the entropy from Windows events such as mouse
  32. movements and other user interaction. It should be called with the
  33. B<iMsg>, B<wParam> and B<lParam> arguments of I<all> messages sent to
  34. the window procedure. It will estimate the entropy contained in the
  35. event message (if any), and add it to the PRNG. The program can then
  36. process the messages as usual.
  37. The RAND_screen() function is available for the convenience of Windows
  38. programmers. It adds the current contents of the screen to the PRNG.
  39. For applications that can catch Windows events, seeding the PRNG by
  40. calling RAND_event() is a significantly better source of
  41. randomness. It should be noted that both methods cannot be used on
  42. servers that run without user interaction.
  43. =head1 RETURN VALUES
  44. RAND_status() and RAND_event() return 1 if the PRNG has been seeded
  45. with enough data, 0 otherwise.
  46. The other functions do not return values.
  47. =head1 SEE ALSO
  48. L<rand(3)|rand(3)>, L<RAND_egd(3)|RAND_egd(3)>,
  49. L<RAND_load_file(3)|RAND_load_file(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
  50. =head1 HISTORY
  51. RAND_seed() and RAND_screen() are available in all versions of SSLeay
  52. and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL
  53. 0.9.5, RAND_event() in OpenSSL 0.9.5a.
  54. =cut