RAND_set_rand_method.pod 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. =pod
  2. =head1 NAME
  3. RAND_set_rand_method, RAND_get_rand_method, RAND_OpenSSL - select RAND method
  4. =head1 SYNOPSIS
  5. #include <openssl/rand.h>
  6. RAND_METHOD *RAND_OpenSSL(void);
  7. int RAND_set_rand_method(const RAND_METHOD *meth);
  8. const RAND_METHOD *RAND_get_rand_method(void);
  9. =head1 DESCRIPTION
  10. A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
  11. generation.
  12. RAND_OpenSSL() returns the default B<RAND_METHOD> implementation by OpenSSL.
  13. This implementation ensures that the PRNG state is unique for each thread.
  14. If an B<ENGINE> is loaded that provides the RAND API, however, it will
  15. be used instead of the method returned by RAND_OpenSSL(). This is deprecated
  16. in OpenSSL 3.0.
  17. RAND_set_rand_method() makes B<meth> the method for PRNG use. If an
  18. ENGINE was providing the method, it will be released first.
  19. RAND_get_rand_method() returns a pointer to the current B<RAND_METHOD>.
  20. =head1 THE RAND_METHOD STRUCTURE
  21. typedef struct rand_meth_st {
  22. int (*seed)(const void *buf, int num);
  23. int (*bytes)(unsigned char *buf, int num);
  24. void (*cleanup)(void);
  25. int (*add)(const void *buf, int num, double entropy);
  26. int (*pseudorand)(unsigned char *buf, int num);
  27. int (*status)(void);
  28. } RAND_METHOD;
  29. The fields point to functions that are used by, in order,
  30. RAND_seed(), RAND_bytes(), internal RAND cleanup, RAND_add(), RAND_pseudo_rand()
  31. and RAND_status().
  32. Each pointer may be NULL if the function is not implemented.
  33. =head1 RETURN VALUES
  34. RAND_set_rand_method() returns 1 on success and 0 on failure.
  35. RAND_get_rand_method() and RAND_OpenSSL() return pointers to the respective
  36. methods.
  37. =head1 SEE ALSO
  38. L<RAND_bytes(3)>,
  39. L<ENGINE_by_id(3)>,
  40. L<RAND(7)>
  41. =head1 HISTORY
  42. The ability for an B<ENGINE> to replace the RAND API was deprecated in
  43. OpenSSL 3.0.
  44. =head1 COPYRIGHT
  45. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  46. Licensed under the Apache License 2.0 (the "License"). You may not use
  47. this file except in compliance with the License. You can obtain a copy
  48. in the file LICENSE in the source distribution or at
  49. L<https://www.openssl.org/source/license.html>.
  50. =cut