RAND_get0_primary.pod 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. =pod
  2. =head1 NAME
  3. RAND_get0_primary,
  4. RAND_get0_public,
  5. RAND_get0_private
  6. - get access to the global EVP_RAND_CTX instances
  7. =head1 SYNOPSIS
  8. #include <openssl/rand.h>
  9. EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx);
  10. EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx);
  11. EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx);
  12. =head1 DESCRIPTION
  13. The default RAND API implementation (RAND_OpenSSL()) utilizes three
  14. shared DRBG instances which are accessed via the RAND API:
  15. The I<public> and I<private> DRBG are thread-local instances, which are used
  16. by RAND_bytes() and RAND_priv_bytes(), respectively.
  17. The I<primary> DRBG is a global instance, which is not intended to be used
  18. directly, but is used internally to reseed the other two instances.
  19. These functions here provide access to the shared DRBG instances.
  20. =head1 RETURN VALUES
  21. RAND_get0_primary() returns a pointer to the I<primary> DRBG instance
  22. for the given OSSL_LIB_CTX B<ctx>.
  23. RAND_get0_public() returns a pointer to the I<public> DRBG instance
  24. for the given OSSL_LIB_CTX B<ctx>.
  25. RAND_get0_private() returns a pointer to the I<private> DRBG instance
  26. for the given OSSL_LIB_CTX B<ctx>.
  27. In all the above cases the B<ctx> parameter can
  28. be NULL in which case the default OSSL_LIB_CTX is used.
  29. =head1 NOTES
  30. It is not thread-safe to access the I<primary> DRBG instance.
  31. The I<public> and I<private> DRBG instance can be accessed safely, because
  32. they are thread-local. Note however, that changes to these two instances
  33. apply only to the current thread.
  34. For that reason it is recommended not to change the settings of these
  35. three instances directly.
  36. Instead, an application should change the default settings for new DRBG instances
  37. at initialization time, before creating additional threads.
  38. During initialization, it is possible to change the reseed interval
  39. and reseed time interval.
  40. It is also possible to exchange the reseeding callbacks entirely.
  41. To set the type of DRBG that will be instantiated, use the
  42. L<RAND_set_DRBG_type(3)> call before accessing the random number generation
  43. infrastructure.
  44. =head1 SEE ALSO
  45. L<EVP_RAND(3)>,
  46. L<RAND_set_DRBG_type(3)>
  47. =head1 HISTORY
  48. These functions were added in OpenSSL 3.0.
  49. =head1 COPYRIGHT
  50. Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  51. Licensed under the Apache License 2.0 (the "License"). You may not use
  52. this file except in compliance with the License. You can obtain a copy
  53. in the file LICENSE in the source distribution or at
  54. L<https://www.openssl.org/source/license.html>.
  55. =cut