RAND_get0_primary.pod 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. =head1 SEE ALSO
  42. L<EVP_RAND(3)>
  43. =head1 HISTORY
  44. These functions were added in OpenSSL 3.0.
  45. =head1 COPYRIGHT
  46. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  47. Licensed under the Apache License 2.0 (the "License"). You may not use
  48. this file except in compliance with the License. You can obtain a copy
  49. in the file LICENSE in the source distribution or at
  50. L<https://www.openssl.org/source/license.html>.
  51. =cut