RAND_egd.pod 1.9 KB
Newer Older
U
Ulf Möller 已提交
1 2 3 4
=pod

=head1 NAME

M
Matt Caswell 已提交
5
RAND_egd, RAND_egd_bytes, RAND_query_egd_bytes - query entropy gathering daemon
U
Ulf Möller 已提交
6 7 8 9 10

=head1 SYNOPSIS

 #include <openssl/rand.h>

R
Rich Salz 已提交
11
 int RAND_egd_bytes(const char *path, int num);
U
Ulf Möller 已提交
12
 int RAND_egd(const char *path);
13

R
Rich Salz 已提交
14
 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int num);
U
Ulf Möller 已提交
15 16 17

=head1 DESCRIPTION

R
Rich Salz 已提交
18 19 20 21 22 23 24 25 26 27 28
On older platforms without a good source of randomness such as C</dev/urandom>,
it is possible to query an Entropy Gathering Daemon (EGD) over a local
socket to obtain randomness and seed the OpenSSL RNG.
The protocol used is defined by the EGDs available at
L<http://egd.sourceforge.net/> or L<http://prngd.sourceforge.net>.

RAND_egd_bytes() requests B<num> bytes of randomness from an EGD at the
specified socket B<path>, and passes the data it receives into RAND_add().
RAND_egd() is equivalent to RAND_egd_bytes() with B<num> set to 255.

RAND_query_egd_bytes() requests B<num> bytes of randomness from an EGD at
R
Rich Salz 已提交
29
the specified socket B<path>, where B<num> must be less than 256.
R
Rich Salz 已提交
30 31 32 33 34 35
If B<buf> is B<NULL>, it is equivalent to RAND_egd_bytes().
If B<buf> is not B<NULL>, then the data is copied to the buffer and
RAND_add() is not called.

OpenSSL can be configured at build time to try to use the EGD for seeding
automatically.
36

37
=head1 RETURN VALUES
U
Ulf Möller 已提交
38

39
RAND_egd() and RAND_egd_bytes() return the number of bytes read from the
R
Rich Salz 已提交
40
daemon on success, or -1 if the connection failed or the daemon did not
41 42 43
return enough data to fully seed the PRNG.

RAND_query_egd_bytes() returns the number of bytes read from the daemon on
R
Rich Salz 已提交
44
success, or -1 if the connection failed.
U
Ulf Möller 已提交
45 46 47

=head1 SEE ALSO

48 49 50
L<RAND_add(3)>,
L<RAND_bytes(3)>,
L<RAND(7)>
U
Ulf Möller 已提交
51

R
Rich Salz 已提交
52 53
=head1 COPYRIGHT

54
Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
R
Rich Salz 已提交
55 56 57 58 59 60 61

Licensed under the OpenSSL license (the "License").  You may not use
this file except in compliance with the License.  You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.

=cut