RAND_DRBG_generate.pod 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. =pod
  2. =head1 NAME
  3. RAND_DRBG_generate,
  4. RAND_DRBG_bytes
  5. - generate random bytes using the given drbg instance
  6. =head1 SYNOPSIS
  7. #include <openssl/rand_drbg.h>
  8. int RAND_DRBG_generate(RAND_DRBG *drbg,
  9. unsigned char *out, size_t outlen,
  10. int prediction_resistance,
  11. const unsigned char *adin, size_t adinlen);
  12. int RAND_DRBG_bytes(RAND_DRBG *drbg,
  13. unsigned char *out, size_t outlen);
  14. =head1 DESCRIPTION
  15. RAND_DRBG_generate() generates B<outlen> random bytes using the given
  16. DRBG instance B<drbg> and stores them in the buffer at B<out>.
  17. Before generating the output, the DRBG instance checks whether the maximum
  18. number of generate requests (I<reseed interval>) or the maximum timespan
  19. (I<reseed time interval>) since its last seeding have been reached.
  20. If this is the case, the DRBG reseeds automatically.
  21. Additionally, an immediate reseeding can be requested by setting the
  22. B<prediction_resistance> flag to 1. See NOTES section for more details.
  23. The caller can optionally provide additional data to be used for reseeding
  24. by passing a pointer B<adin> to a buffer of length B<adinlen>.
  25. This additional data is mixed into the internal state of the random
  26. generator but does not contribute to the entropy count.
  27. The additional data can be omitted by setting B<adin> to NULL and
  28. B<adinlen> to 0;
  29. RAND_DRBG_bytes() generates B<outlen> random bytes using the given
  30. DRBG instance B<drbg> and stores them in the buffer at B<out>.
  31. This function is a wrapper around the RAND_DRBG_generate() call,
  32. which collects some additional data from low entropy sources
  33. (e.g., a high resolution timer) and calls
  34. RAND_DRBG_generate(drbg, out, outlen, 0, adin, adinlen).
  35. =head1 RETURN VALUES
  36. RAND_DRBG_generate() and RAND_DRBG_bytes() return 1 on success,
  37. and 0 on failure.
  38. =head1 NOTES
  39. The I<reseed interval> and I<reseed time interval> of the B<drbg> are set to
  40. reasonable default values, which in general do not have to be adjusted.
  41. If necessary, they can be changed using L<RAND_DRBG_set_reseed_interval(3)>
  42. and L<RAND_DRBG_set_reseed_time_interval(3)>, respectively.
  43. A request for prediction resistance can only be satisfied by pulling fresh
  44. entropy from one of the approved entropy sources listed in section 5.5.2 of
  45. [NIST SP 800-90C].
  46. Since the default DRBG implementation does not have access to such an approved
  47. entropy source, a request for prediction resistance will always fail.
  48. In other words, prediction resistance is currently not supported yet by the DRBG.
  49. =head1 HISTORY
  50. The RAND_DRBG functions were added in OpenSSL 1.1.1.
  51. =head1 SEE ALSO
  52. L<RAND_bytes(3)>,
  53. L<RAND_DRBG_set_reseed_interval(3)>,
  54. L<RAND_DRBG_set_reseed_time_interval(3)>,
  55. L<RAND_DRBG(7)>
  56. =head1 COPYRIGHT
  57. Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  58. Licensed under the OpenSSL license (the "License"). You may not use
  59. this file except in compliance with the License. You can obtain a copy
  60. in the file LICENSE in the source distribution or at
  61. L<https://www.openssl.org/source/license.html>.
  62. =cut