Add --with-rand-seed
[openssl.git] / doc / man3 / RAND_add.pod
1 =pod
2
3 =head1 NAME
4
5 RAND_add, RAND_poll, RAND_seed, RAND_status, RAND_event, RAND_screen
6 - add randomness to the PRNG or get its status
7
8 =head1 SYNOPSIS
9
10  #include <openssl/rand.h>
11
12  int RAND_status(void);
13  int RAND_poll()
14
15  void RAND_add(const void *buf, int num, double randomness);
16  void RAND_seed(const void *buf, int num);
17
18 Deprecated:
19
20  #if OPENSSL_API_COMPAT < 0x10100000L
21  int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam);
22  void RAND_screen(void);
23  #endif
24
25 =head1 DESCRIPTION
26
27 Random numbers are a vital part of cryptography, including key generation,
28 creating salts, etc., and software-based
29 generators must be "seeded" with external randomness before they can be
30 used as a cryptographically-secure pseudo-random number generator (CSPRNG).
31 The availability of common hardware with special instructions and
32 modern operating systems, which may use items such as interrupt jitter
33 and network packet timings, can be reasonable sources of seeding material.
34
35 RAND_status() indicates whether or not the CSPRNG has been sufficiently
36 seeded. If not, functions such as RAND_bytes(3) will fail.
37
38 RAND_poll() uses the current capabilities to seed the CSPRNG. The
39 exact features used depends on how OpenSSL was configured, and can
40 be displayed with the OpenSSL L<version(1)> command. This function is
41 normally called automatically during OpenSSL initialization, but
42 can be called by the application to reseed the CSPRNG.
43
44 RAND_add() mixes the B<num> bytes at B<buf> into the PRNG state.
45 The B<randomness> argument is an estimate of how much randomness is
46 contained in
47 B<buf>, in bytes, and should be a number between zero and B<num>.
48 Details about sources of randomness and how to estimate their randomness
49 can be found in the literature; for example NIST SP 800-90B.
50 The content of B<buf> cannot be recovered from subsequent CSPRNG output.
51 This function will not normally be needed, as RAND_poll() should have been
52 configured to do the appropriate seeding for the local platform.
53 Applications that need to keep random state in an external file should
54 use L<RAND_load_file(3)>.
55
56 RAND_seed() is equivalent to RAND_add() with B<randomness> set to B<num>.
57
58 RAND_event() and RAND_screen() are equivalent to RAND_poll().
59
60 =head1 RETURN VALUES
61
62 RAND_status() returns 1 if the CSPRNG has been seeded
63 with enough data, 0 otherwise.
64
65 RAND_poll() returns 1 if it generated seed data, 0 otherwise.
66
67 RAND_event() returns RAND_status().
68
69 The other functions do not return values.
70
71 =head1 HISTORY
72
73 RAND_event() and RAND_screen() were deprecated in OpenSSL 1.1.0 and should
74 not be used.
75
76 =head1 SEE ALSO
77
78 L<RAND_bytes(3)>, L<RAND_egd(3)>,
79 L<RAND_load_file(3)>
80
81 =head1 COPYRIGHT
82
83 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
84
85 Licensed under the OpenSSL license (the "License").  You may not use
86 this file except in compliance with the License.  You can obtain a copy
87 in the file LICENSE in the source distribution or at
88 L<https://www.openssl.org/source/license.html>.
89
90 =cut