1RAND_add(3)                         OpenSSL                        RAND_add(3)
2
3
4

NAME

6       RAND_add, RAND_seed, RAND_status, RAND_event, RAND_screen - add entropy
7       to the PRNG
8

SYNOPSIS

10        #include <openssl/rand.h>
11
12        void RAND_seed(const void *buf, int num);
13
14        void RAND_add(const void *buf, int num, double entropy);
15
16        int  RAND_status(void);
17
18        int  RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
19        void RAND_screen(void);
20

DESCRIPTION

22       RAND_add() mixes the num bytes at buf into the PRNG state. Thus, if the
23       data at buf are unpredictable to an adversary, this increases the
24       uncertainty about the state and makes the PRNG output less predictable.
25       Suitable input comes from user interaction (random key presses, mouse
26       movements) and certain hardware events. The entropy argument is (the
27       lower bound of) an estimate of how much randomness is contained in buf,
28       measured in bytes. Details about sources of randomness and how to
29       estimate their entropy can be found in the literature, e.g. RFC 1750.
30
31       RAND_add() may be called with sensitive data such as user entered
32       passwords. The seed values cannot be recovered from the PRNG output.
33
34       OpenSSL makes sure that the PRNG state is unique for each thread. On
35       systems that provide "/dev/urandom", the randomness device is used to
36       seed the PRNG transparently. However, on all other systems, the
37       application is responsible for seeding the PRNG by calling RAND_add(),
38       RAND_egd(3) or RAND_load_file(3).
39
40       RAND_seed() is equivalent to RAND_add() when num == entropy.
41
42       RAND_event() collects the entropy from Windows events such as mouse
43       movements and other user interaction. It should be called with the
44       iMsg, wParam and lParam arguments of all messages sent to the window
45       procedure. It will estimate the entropy contained in the event message
46       (if any), and add it to the PRNG. The program can then process the
47       messages as usual.
48
49       The RAND_screen() function is available for the convenience of Windows
50       programmers. It adds the current contents of the screen to the PRNG.
51       For applications that can catch Windows events, seeding the PRNG by
52       calling RAND_event() is a significantly better source of randomness. It
53       should be noted that both methods cannot be used on servers that run
54       without user interaction.
55

RETURN VALUES

57       RAND_status() and RAND_event() return 1 if the PRNG has been seeded
58       with enough data, 0 otherwise.
59
60       The other functions do not return values.
61

SEE ALSO

63       rand(3), RAND_egd(3), RAND_load_file(3), RAND_cleanup(3)
64

HISTORY

66       RAND_seed() and RAND_screen() are available in all versions of SSLeay
67       and OpenSSL. RAND_add() and RAND_status() have been added in OpenSSL
68       0.9.5, RAND_event() in OpenSSL 0.9.5a.
69
70
71
721.0.2o                            2020-01-28                       RAND_add(3)
Impressum