RAND_add.pod 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. =pod
  2. =head1 NAME
  3. RAND_add, RAND_poll, RAND_seed, RAND_status, RAND_event, RAND_screen,
  4. RAND_keep_random_devices_open
  5. - add randomness to the PRNG or get its status
  6. =head1 SYNOPSIS
  7. #include <openssl/rand.h>
  8. int RAND_status(void);
  9. int RAND_poll();
  10. void RAND_add(const void *buf, int num, double randomness);
  11. void RAND_seed(const void *buf, int num);
  12. void RAND_keep_random_devices_open(int keep);
  13. Deprecated:
  14. #if OPENSSL_API_COMPAT < 0x10100000L
  15. int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
  16. void RAND_screen(void);
  17. #endif
  18. =head1 DESCRIPTION
  19. These functions can be used to seed the random generator and to check its
  20. seeded state.
  21. In general, manual (re-)seeding of the default OpenSSL random generator
  22. (L<RAND_OpenSSL(3)>) is not necessary (but allowed), since it does (re-)seed
  23. itself automatically using trusted system entropy sources.
  24. This holds unless the default RAND_METHOD has been replaced or OpenSSL was
  25. built with automatic reseeding disabled, see L<RAND(7)> for more details.
  26. RAND_status() indicates whether or not the random generator has been sufficiently
  27. seeded. If not, functions such as L<RAND_bytes(3)> will fail.
  28. RAND_poll() uses the system's capabilities to seed the random generator using
  29. random input obtained from polling various trusted entropy sources.
  30. The default choice of the entropy source can be modified at build time,
  31. see L<RAND(7)> for more details.
  32. RAND_add() mixes the B<num> bytes at B<buf> into the internal state
  33. of the random generator.
  34. This function will not normally be needed, as mentioned above.
  35. The B<randomness> argument is an estimate of how much randomness is
  36. contained in
  37. B<buf>, in bytes, and should be a number between zero and B<num>.
  38. Details about sources of randomness and how to estimate their randomness
  39. can be found in the literature; for example [NIST SP 800-90B].
  40. The content of B<buf> cannot be recovered from subsequent random generator output.
  41. Applications that intend to save and restore random state in an external file
  42. should consider using L<RAND_load_file(3)> instead.
  43. RAND_seed() is equivalent to RAND_add() with B<randomness> set to B<num>.
  44. RAND_keep_random_devices_open() is used to control file descriptor
  45. usage by the random seed sources. Some seed sources maintain open file
  46. descriptors by default, which allows such sources to operate in a
  47. chroot(2) jail without the associated device nodes being available. When
  48. the B<keep> argument is zero, this call disables the retention of file
  49. descriptors. Conversely, a nonzero argument enables the retention of
  50. file descriptors. This function is usually called during initialization
  51. and it takes effect immediately.
  52. RAND_event() and RAND_screen() are equivalent to RAND_poll() and exist
  53. for compatibility reasons only. See HISTORY section below.
  54. =head1 RETURN VALUES
  55. RAND_status() returns 1 if the random generator has been seeded
  56. with enough data, 0 otherwise.
  57. RAND_poll() returns 1 if it generated seed data, 0 otherwise.
  58. RAND_event() returns RAND_status().
  59. The other functions do not return values.
  60. =head1 SEE ALSO
  61. L<RAND_bytes(3)>,
  62. L<RAND_egd(3)>,
  63. L<RAND_load_file(3)>,
  64. L<RAND(7)>
  65. =head1 HISTORY
  66. RAND_event() and RAND_screen() were deprecated in OpenSSL 1.1.0 and should
  67. not be used.
  68. =head1 COPYRIGHT
  69. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  70. Licensed under the OpenSSL license (the "License"). You may not use
  71. this file except in compliance with the License. You can obtain a copy
  72. in the file LICENSE in the source distribution or at
  73. L<https://www.openssl.org/source/license.html>.
  74. =cut