1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948RAND_set_rand_method, RAND_get_rand_method, RAND_SSLeay - select RAND method 6*2175Sjp161948 7*2175Sjp161948=head1 SYNOPSIS 8*2175Sjp161948 9*2175Sjp161948 #include <openssl/rand.h> 10*2175Sjp161948 11*2175Sjp161948 void RAND_set_rand_method(const RAND_METHOD *meth); 12*2175Sjp161948 13*2175Sjp161948 const RAND_METHOD *RAND_get_rand_method(void); 14*2175Sjp161948 15*2175Sjp161948 RAND_METHOD *RAND_SSLeay(void); 16*2175Sjp161948 17*2175Sjp161948=head1 DESCRIPTION 18*2175Sjp161948 19*2175Sjp161948A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number 20*2175Sjp161948generation. By modifying the method, alternative implementations such as 21*2175Sjp161948hardware RNGs may be used. IMPORTANT: See the NOTES section for important 22*2175Sjp161948information about how these RAND API functions are affected by the use of 23*2175Sjp161948B<ENGINE> API calls. 24*2175Sjp161948 25*2175Sjp161948Initially, the default RAND_METHOD is the OpenSSL internal implementation, as 26*2175Sjp161948returned by RAND_SSLeay(). 27*2175Sjp161948 28*2175Sjp161948RAND_set_default_method() makes B<meth> the method for PRNG use. B<NB>: This is 29*2175Sjp161948true only whilst no ENGINE has been set as a default for RAND, so this function 30*2175Sjp161948is no longer recommended. 31*2175Sjp161948 32*2175Sjp161948RAND_get_default_method() returns a pointer to the current RAND_METHOD. 33*2175Sjp161948However, the meaningfulness of this result is dependant on whether the ENGINE 34*2175Sjp161948API is being used, so this function is no longer recommended. 35*2175Sjp161948 36*2175Sjp161948=head1 THE RAND_METHOD STRUCTURE 37*2175Sjp161948 38*2175Sjp161948 typedef struct rand_meth_st 39*2175Sjp161948 { 40*2175Sjp161948 void (*seed)(const void *buf, int num); 41*2175Sjp161948 int (*bytes)(unsigned char *buf, int num); 42*2175Sjp161948 void (*cleanup)(void); 43*2175Sjp161948 void (*add)(const void *buf, int num, int entropy); 44*2175Sjp161948 int (*pseudorand)(unsigned char *buf, int num); 45*2175Sjp161948 int (*status)(void); 46*2175Sjp161948 } RAND_METHOD; 47*2175Sjp161948 48*2175Sjp161948The components point to the implementation of RAND_seed(), 49*2175Sjp161948RAND_bytes(), RAND_cleanup(), RAND_add(), RAND_pseudo_rand() 50*2175Sjp161948and RAND_status(). 51*2175Sjp161948Each component may be NULL if the function is not implemented. 52*2175Sjp161948 53*2175Sjp161948=head1 RETURN VALUES 54*2175Sjp161948 55*2175Sjp161948RAND_set_rand_method() returns no value. RAND_get_rand_method() and 56*2175Sjp161948RAND_SSLeay() return pointers to the respective methods. 57*2175Sjp161948 58*2175Sjp161948=head1 NOTES 59*2175Sjp161948 60*2175Sjp161948As of version 0.9.7, RAND_METHOD implementations are grouped together with other 61*2175Sjp161948algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a 62*2175Sjp161948default ENGINE is specified for RAND functionality using an ENGINE API function, 63*2175Sjp161948that will override any RAND defaults set using the RAND API (ie. 64*2175Sjp161948RAND_set_rand_method()). For this reason, the ENGINE API is the recommended way 65*2175Sjp161948to control default implementations for use in RAND and other cryptographic 66*2175Sjp161948algorithms. 67*2175Sjp161948 68*2175Sjp161948=head1 SEE ALSO 69*2175Sjp161948 70*2175Sjp161948L<rand(3)|rand(3)>, L<engine(3)|engine(3)> 71*2175Sjp161948 72*2175Sjp161948=head1 HISTORY 73*2175Sjp161948 74*2175Sjp161948RAND_set_rand_method(), RAND_get_rand_method() and RAND_SSLeay() are 75*2175Sjp161948available in all versions of OpenSSL. 76*2175Sjp161948 77*2175Sjp161948In the engine version of version 0.9.6, RAND_set_rand_method() was altered to 78*2175Sjp161948take an ENGINE pointer as its argument. As of version 0.9.7, that has been 79*2175Sjp161948reverted as the ENGINE API transparently overrides RAND defaults if used, 80*2175Sjp161948otherwise RAND API functions work as before. RAND_set_rand_engine() was also 81*2175Sjp161948introduced in version 0.9.7. 82*2175Sjp161948 83*2175Sjp161948=cut 84