2
0

RAND_set_rand_method.pod 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. =pod
  2. =head1 NAME
  3. RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method
  4. =head1 SYNOPSIS
  5. #include <openssl/rand.h>
  6. void RAND_set_rand_method(const RAND_METHOD *meth);
  7. const RAND_METHOD *RAND_get_rand_method(void);
  8. RAND_METHOD *RAND_SSLeay(void);
  9. =head1 DESCRIPTION
  10. A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
  11. generation. By modifying the method, alternative implementations such as
  12. hardware RNGs may be used. IMPORTANT: See the NOTES section for important
  13. information about how these RAND API functions are affected by the use of
  14. B<ENGINE> API calls.
  15. Initially, the default RAND_METHOD is the OpenSSL internal implementation, as
  16. returned by RAND_SSLeay().
  17. RAND_set_default_method() makes B<meth> the method for PRNG use. B<NB>: This is
  18. true only whilst no ENGINE has been set as a default for RAND, so this function
  19. is no longer recommended.
  20. RAND_get_default_method() returns a pointer to the current RAND_METHOD.
  21. However, the meaningfulness of this result is dependent on whether the ENGINE
  22. API is being used, so this function is no longer recommended.
  23. =head1 THE RAND_METHOD STRUCTURE
  24. typedef struct rand_meth_st
  25. {
  26. void (*seed)(const void *buf, int num);
  27. int (*bytes)(unsigned char *buf, int num);
  28. void (*cleanup)(void);
  29. void (*add)(const void *buf, int num, int entropy);
  30. int (*pseudorand)(unsigned char *buf, int num);
  31. int (*status)(void);
  32. } RAND_METHOD;
  33. The components point to the implementation of RAND_seed(),
  34. RAND_bytes(), RAND_cleanup(), RAND_add(), RAND_pseudo_rand()
  35. and RAND_status().
  36. Each component may be NULL if the function is not implemented.
  37. =head1 RETURN VALUES
  38. RAND_set_rand_method() returns no value. RAND_get_rand_method() and
  39. RAND_SSLeay() return pointers to the respective methods.
  40. =head1 NOTES
  41. As of version 0.9.7, RAND_METHOD implementations are grouped together with other
  42. algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
  43. default ENGINE is specified for RAND functionality using an ENGINE API function,
  44. that will override any RAND defaults set using the RAND API (ie.
  45. RAND_set_rand_method()). For this reason, the ENGINE API is the recommended way
  46. to control default implementations for use in RAND and other cryptographic
  47. algorithms.
  48. =head1 SEE ALSO
  49. L<rand(3)|rand(3)>, L<engine(3)|engine(3)>
  50. =head1 HISTORY
  51. RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are
  52. available in all versions of OpenSSL.
  53. In the engine version of version 0.9.6, RAND_set_rand_method() was altered to
  54. take an ENGINE pointer as its argument. As of version 0.9.7, that has been
  55. reverted as the ENGINE API transparently overrides RAND defaults if used,
  56. otherwise RAND API functions work as before. RAND_set_rand_engine() was also
  57. introduced in version 0.9.7.
  58. =cut