1RAND_ADD(3) OpenSSL RAND_ADD(3)
2
3
4
6 RAND_add, RAND_poll, RAND_seed, RAND_status, RAND_event, RAND_screen,
7 RAND_keep_random_devices_open - add randomness to the PRNG or get its
8 status
9
11 #include <openssl/rand.h>
12
13 int RAND_status(void);
14 int RAND_poll();
15
16 void RAND_add(const void *buf, int num, double randomness);
17 void RAND_seed(const void *buf, int num);
18
19 void RAND_keep_random_devices_open(int keep);
20
21 Deprecated:
22
23 #if OPENSSL_API_COMPAT < 0x10100000L
24 int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
25 void RAND_screen(void);
26 #endif
27
29 These functions can be used to seed the random generator and to check
30 its seeded state. In general, manual (re-)seeding of the default
31 OpenSSL random generator (RAND_OpenSSL(3)) is not necessary (but
32 allowed), since it does (re-)seed itself automatically using trusted
33 system entropy sources. This holds unless the default RAND_METHOD has
34 been replaced or OpenSSL was built with automatic reseeding disabled,
35 see RAND(7) for more details.
36
37 RAND_status() indicates whether or not the random generator has been
38 sufficiently seeded. If not, functions such as RAND_bytes(3) will fail.
39
40 RAND_poll() uses the system's capabilities to seed the random generator
41 using random input obtained from polling various trusted entropy
42 sources. The default choice of the entropy source can be modified at
43 build time, see RAND(7) for more details.
44
45 RAND_add() mixes the num bytes at buf into the internal state of the
46 random generator. This function will not normally be needed, as
47 mentioned above. The randomness argument is an estimate of how much
48 randomness is contained in buf, in bytes, and should be a number
49 between zero and num. Details about sources of randomness and how to
50 estimate their randomness can be found in the literature; for example
51 [NIST SP 800-90B]. The content of buf cannot be recovered from
52 subsequent random generator output. Applications that intend to save
53 and restore random state in an external file should consider using
54 RAND_load_file(3) instead.
55
56 RAND_seed() is equivalent to RAND_add() with randomness set to num.
57
58 RAND_keep_random_devices_open() is used to control file descriptor
59 usage by the random seed sources. Some seed sources maintain open file
60 descriptors by default, which allows such sources to operate in a
61 chroot(2) jail without the associated device nodes being available.
62 When the keep argument is zero, this call disables the retention of
63 file descriptors. Conversely, a non-zero argument enables the retention
64 of file descriptors. This function is usually called during
65 initialization and it takes effect immediately.
66
67 RAND_event() and RAND_screen() are equivalent to RAND_poll() and exist
68 for compatibility reasons only. See HISTORY section below.
69
71 RAND_status() returns 1 if the random generator has been seeded with
72 enough data, 0 otherwise.
73
74 RAND_poll() returns 1 if it generated seed data, 0 otherwise.
75
76 RAND_event() returns RAND_status().
77
78 The other functions do not return values.
79
81 RAND_event() and RAND_screen() were deprecated in OpenSSL 1.1.0 and
82 should not be used.
83
85 RAND_bytes(3), RAND_egd(3), RAND_load_file(3), RAND(7)
86
88 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
89
90 Licensed under the OpenSSL license (the "License"). You may not use
91 this file except in compliance with the License. You can obtain a copy
92 in the file LICENSE in the source distribution or at
93 <https://www.openssl.org/source/license.html>.
94
95
96
971.1.1 2018-09-11 RAND_ADD(3)