RAND_set_rand_method.pod 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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().
  16. RAND_set_rand_method() makes B<meth> the method for PRNG use. If an
  17. ENGINE was providing the method, it will be released first.
  18. RAND_get_rand_method() returns a pointer to the current B<RAND_METHOD>.
  19. =head1 THE RAND_METHOD STRUCTURE
  20. typedef struct rand_meth_st {
  21. int (*seed)(const void *buf, int num);
  22. int (*bytes)(unsigned char *buf, int num);
  23. void (*cleanup)(void);
  24. int (*add)(const void *buf, int num, double entropy);
  25. int (*pseudorand)(unsigned char *buf, int num);
  26. int (*status)(void);
  27. } RAND_METHOD;
  28. The fields point to functions that are used by, in order,
  29. RAND_seed(), RAND_bytes(), internal RAND cleanup, RAND_add(), RAND_pseudo_rand()
  30. and RAND_status().
  31. Each pointer may be NULL if the function is not implemented.
  32. =head1 RETURN VALUES
  33. RAND_set_rand_method() returns 1 on success and 0 on failure.
  34. RAND_get_rand_method() and RAND_OpenSSL() return pointers to the respective
  35. methods.
  36. =head1 SEE ALSO
  37. L<RAND_bytes(3)>,
  38. L<ENGINE_by_id(3)>,
  39. L<RAND(7)>
  40. =head1 COPYRIGHT
  41. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  42. Licensed under the Apache License 2.0 (the "License"). You may not use
  43. this file except in compliance with the License. You can obtain a copy
  44. in the file LICENSE in the source distribution or at
  45. L<https://www.openssl.org/source/license.html>.
  46. =cut