ossl_rand_get_entropy.pod 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. =pod
  2. =head1 NAME
  3. ossl_rand_get_entropy, ossl_rand_cleanup_entropy,
  4. ossl_rand_get_nonce, ossl_rand_cleanup_nonce
  5. - get seed material from the operating system
  6. =head1 SYNOPSIS
  7. #include "crypto/rand.h"
  8. size_t ossl_rand_get_entropy(OSSL_CORE_HANDLE *handle,
  9. unsigned char **pout, int entropy,
  10. size_t min_len, size_t max_len);
  11. void ossl_rand_cleanup_entropy(OSSL_CORE_HANDLE *handle,
  12. unsigned char *buf, size_t len);
  13. size_t ossl_rand_get_nonce(OSSL_CORE_HANDLE *handle,
  14. unsigned char **pout, size_t min_len,
  15. size_t max_len, const void *salt, size_t salt_len);
  16. void ossl_rand_cleanup_nonce(OSSL_CORE_HANDLE *handle,
  17. unsigned char *buf, size_t len);
  18. =head1 DESCRIPTION
  19. ossl_rand_get_entropy() retrieves seeding material from the operating system.
  20. The seeding material will have at least I<entropy> bytes of randomness and is
  21. stored in a buffer which contains at least I<min_len> and at most I<max_len>
  22. bytes. The buffer address is stored in I<*pout> and the buffer length is
  23. returned to the caller.
  24. ossl_rand_cleanup_entropy() cleanses and frees any storage allocated by
  25. ossl_rand_get_entropy(). The seeding buffer is pointed to by I<buf> and is
  26. of length I<len> bytes.
  27. ossl_rand_get_nonce() retrieves a nonce using the passed I<salt> parameter
  28. of length I<salt_len> and operating system specific information.
  29. The I<salt> should contain uniquely identifying information and this is
  30. included, in an unspecified manner, as part of the output.
  31. The output is stored in a buffer which contains at least I<min_len> and at
  32. most I<max_len> bytes. The buffer address is stored in I<*pout> and the
  33. buffer length returned to the caller.
  34. ossl_rand_cleanup_nonce() cleanses and frees any storage allocated by
  35. ossl_rand_get_nonce(). The nonce buffer is pointed to by I<buf> and is
  36. of length I<len> bytes.
  37. =head1 RETURN VALUES
  38. ossl_rand_get_entropy() and ossl_rand_get_nonce() return the number of bytes
  39. in I<*pout> or 0 on error.
  40. =head1 HISTORY
  41. The functions described here were all added in OpenSSL 3.0.
  42. =head1 COPYRIGHT
  43. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  44. Licensed under the Apache License 2.0 (the "License"). You may not use
  45. this file except in compliance with the License. You can obtain a copy
  46. in the file LICENSE in the source distribution or at
  47. L<https://www.openssl.org/source/license.html>.
  48. =cut