RAND_get0_primary.pod 3.0 KB

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