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