xref: /freebsd/crypto/openssl/doc/man3/RAND_add.pod (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1=pod
2
3=head1 NAME
4
5RAND_add, RAND_poll, RAND_seed, RAND_status, RAND_event, RAND_screen,
6RAND_keep_random_devices_open
7- add randomness to the PRNG or get its status
8
9=head1 SYNOPSIS
10
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
21The following functions have been deprecated since OpenSSL 1.1.0, and can be
22hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
23see L<openssl_user_macros(7)>:
24
25 int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
26 void RAND_screen(void);
27
28=head1 DESCRIPTION
29
30These functions can be used to seed the random generator and to check its
31seeded state.
32In general, manual (re-)seeding of the default OpenSSL random generator
33(L<RAND_OpenSSL(3)>) is not necessary (but allowed), since it does (re-)seed
34itself automatically using trusted system entropy sources.
35This holds unless the default RAND_METHOD has been replaced or OpenSSL was
36built with automatic reseeding disabled, see L<RAND(7)> for more details.
37
38RAND_status() indicates whether or not the random generator has been sufficiently
39seeded. If not, functions such as L<RAND_bytes(3)> will fail.
40
41RAND_poll() uses the system's capabilities to seed the random generator using
42random input obtained from polling various trusted entropy sources.
43The default choice of the entropy source can be modified at build time,
44see L<RAND(7)> for more details.
45
46RAND_add() mixes the B<num> bytes at B<buf> into the internal state
47of the random generator.
48This function will not normally be needed, as mentioned above.
49The B<randomness> argument is an estimate of how much randomness is
50contained in
51B<buf>, in bytes, and should be a number between zero and B<num>.
52Details about sources of randomness and how to estimate their randomness
53can be found in the literature; for example [NIST SP 800-90B].
54The content of B<buf> cannot be recovered from subsequent random generator output.
55Applications that intend to save and restore random state in an external file
56should consider using L<RAND_load_file(3)> instead.
57
58NOTE: In FIPS mode, random data provided by the application is not considered to
59be a trusted entropy source. It is mixed into the internal state of the RNG as
60additional data only and this does not count as a full reseed.
61For more details, see L<EVP_RAND(7)>.
62
63RAND_seed() is equivalent to RAND_add() with B<randomness> set to B<num>.
64
65RAND_keep_random_devices_open() is used to control file descriptor
66usage by the random seed sources. Some seed sources maintain open file
67descriptors by default, which allows such sources to operate in a
68chroot(2) jail without the associated device nodes being available. When
69the B<keep> argument is zero, this call disables the retention of file
70descriptors. Conversely, a nonzero argument enables the retention of
71file descriptors. This function is usually called during initialization
72and it takes effect immediately. This capability only applies to the default
73provider.
74
75RAND_event() and RAND_screen() are equivalent to RAND_poll() and exist
76for compatibility reasons only. See HISTORY section below.
77
78=head1 RETURN VALUES
79
80RAND_status() returns 1 if the random generator has been seeded
81with enough data, 0 otherwise.
82
83RAND_poll() returns 1 if it generated seed data, 0 otherwise.
84
85RAND_event() returns RAND_status().
86
87The other functions do not return values.
88
89=head1 SEE ALSO
90
91L<RAND_bytes(3)>,
92L<RAND_egd(3)>,
93L<RAND_load_file(3)>,
94L<RAND(7)>
95L<EVP_RAND(7)>
96
97=head1 HISTORY
98
99RAND_event() and RAND_screen() were deprecated in OpenSSL 1.1.0 and should
100not be used.
101
102=head1 COPYRIGHT
103
104Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
105
106Licensed under the Apache License 2.0 (the "License").  You may not use
107this file except in compliance with the License.  You can obtain a copy
108in the file LICENSE in the source distribution or at
109L<https://www.openssl.org/source/license.html>.
110
111=cut
112