xref: /onnv-gate/usr/src/common/openssl/doc/crypto/RAND_load_file.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/rand.h>
10*2175Sjp161948
11*2175Sjp161948 const char *RAND_file_name(char *buf, size_t num);
12*2175Sjp161948
13*2175Sjp161948 int RAND_load_file(const char *filename, long max_bytes);
14*2175Sjp161948
15*2175Sjp161948 int RAND_write_file(const char *filename);
16*2175Sjp161948
17*2175Sjp161948=head1 DESCRIPTION
18*2175Sjp161948
19*2175Sjp161948RAND_file_name() generates a default path for the random seed
20*2175Sjp161948file. B<buf> points to a buffer of size B<num> in which to store the
21*2175Sjp161948filename. The seed file is $RANDFILE if that environment variable is
22*2175Sjp161948set, $HOME/.rnd otherwise. If $HOME is not set either, or B<num> is
23*2175Sjp161948too small for the path name, an error occurs.
24*2175Sjp161948
25*2175Sjp161948RAND_load_file() reads a number of bytes from file B<filename> and
26*2175Sjp161948adds them to the PRNG. If B<max_bytes> is non-negative,
27*2175Sjp161948up to to B<max_bytes> are read; starting with OpenSSL 0.9.5,
28*2175Sjp161948if B<max_bytes> is -1, the complete file is read.
29*2175Sjp161948
30*2175Sjp161948RAND_write_file() writes a number of random bytes (currently 1024) to
31*2175Sjp161948file B<filename> which can be used to initialize the PRNG by calling
32*2175Sjp161948RAND_load_file() in a later session.
33*2175Sjp161948
34*2175Sjp161948=head1 RETURN VALUES
35*2175Sjp161948
36*2175Sjp161948RAND_load_file() returns the number of bytes read.
37*2175Sjp161948
38*2175Sjp161948RAND_write_file() returns the number of bytes written, and -1 if the
39*2175Sjp161948bytes written were generated without appropriate seed.
40*2175Sjp161948
41*2175Sjp161948RAND_file_name() returns a pointer to B<buf> on success, and NULL on
42*2175Sjp161948error.
43*2175Sjp161948
44*2175Sjp161948=head1 SEE ALSO
45*2175Sjp161948
46*2175Sjp161948L<rand(3)|rand(3)>, L<RAND_add(3)|RAND_add(3)>, L<RAND_cleanup(3)|RAND_cleanup(3)>
47*2175Sjp161948
48*2175Sjp161948=head1 HISTORY
49*2175Sjp161948
50*2175Sjp161948RAND_load_file(), RAND_write_file() and RAND_file_name() are available in
51*2175Sjp161948all versions of SSLeay and OpenSSL.
52*2175Sjp161948
53*2175Sjp161948=cut
54