RAND.pod 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. =pod
  2. =head1 NAME
  3. RAND
  4. - the OpenSSL random generator
  5. =head1 DESCRIPTION
  6. Random numbers are a vital part of cryptography, they are needed to provide
  7. unpredictability for tasks like key generation, creating salts, and many more.
  8. Software-based generators must be seeded with external randomness before they
  9. can be used as a cryptographically-secure pseudo-random number generator
  10. (CSPRNG).
  11. The availability of common hardware with special instructions and
  12. modern operating systems, which may use items such as interrupt jitter
  13. and network packet timings, can be reasonable sources of seeding material.
  14. OpenSSL comes with a default implementation of the RAND API which is based on
  15. the deterministic random bit generator (DRBG) model as described in
  16. [NIST SP 800-90A Rev. 1]. The default random generator will initialize
  17. automatically on first use and will be fully functional without having
  18. to be initialized ('seeded') explicitly.
  19. It seeds and reseeds itself automatically using trusted random sources
  20. provided by the operating system.
  21. As a normal application developer, you do not have to worry about any details,
  22. just use L<RAND_bytes(3)> to obtain random data.
  23. Having said that, there is one important rule to obey: Always check the error
  24. return value of L<RAND_bytes(3)> and do not take randomness for granted.
  25. For values that should remain secret, you can use L<RAND_priv_bytes(3)>
  26. instead.
  27. This method does not provide 'better' randomness, it uses the same type of CSPRNG.
  28. The intention behind using a dedicated CSPRNG exclusively for private
  29. values is that none of its output should be visible to an attacker (e.g.,
  30. used as salt value), in order to reveal as little information as
  31. possible about its internal state, and that a compromise of the "public"
  32. CSPRNG instance will not affect the secrecy of these private values.
  33. In the rare case where the default implementation does not satisfy your special
  34. requirements, there are two options:
  35. =over 2
  36. =item *
  37. Replace the default RAND method by your own RAND method using
  38. L<RAND_set_rand_method(3)>.
  39. =item *
  40. Modify the default settings of the OpenSSL RAND method by modifying the security
  41. parameters of the underlying DRBG, which is described in detail in L<RAND_DRBG(7)>.
  42. =back
  43. Changing the default random generator or its default parameters should be necessary
  44. only in exceptional cases and is not recommended, unless you have a profound knowledge
  45. of cryptographic principles and understand the implications of your changes.
  46. =head1 SEE ALSO
  47. L<RAND_add(3)>,
  48. L<RAND_bytes(3)>,
  49. L<RAND_priv_bytes(3)>,
  50. L<RAND_get_rand_method(3)>,
  51. L<RAND_set_rand_method(3)>,
  52. L<RAND_OpenSSL(3)>,
  53. L<RAND_DRBG(7)>
  54. =head1 COPYRIGHT
  55. Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
  56. Licensed under the Apache License 2.0 (the "License"). You may not use
  57. this file except in compliance with the License. You can obtain a copy
  58. in the file LICENSE in the source distribution or at
  59. L<https://www.openssl.org/source/license.html>.
  60. =cut