xref: /minix3/crypto/external/bsd/openssl/dist/doc/crypto/RAND_bytes.pod (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc=pod
2*ebfedea0SLionel Sambuc
3*ebfedea0SLionel Sambuc=head1 NAME
4*ebfedea0SLionel Sambuc
5*ebfedea0SLionel SambucRAND_bytes, RAND_pseudo_bytes - generate random data
6*ebfedea0SLionel Sambuc
7*ebfedea0SLionel Sambuc=head1 SYNOPSIS
8*ebfedea0SLionel Sambuc
9*ebfedea0SLionel Sambuc #include <openssl/rand.h>
10*ebfedea0SLionel Sambuc
11*ebfedea0SLionel Sambuc int RAND_bytes(unsigned char *buf, int num);
12*ebfedea0SLionel Sambuc
13*ebfedea0SLionel Sambuc int RAND_pseudo_bytes(unsigned char *buf, int num);
14*ebfedea0SLionel Sambuc
15*ebfedea0SLionel Sambuc=head1 DESCRIPTION
16*ebfedea0SLionel Sambuc
17*ebfedea0SLionel SambucRAND_bytes() puts B<num> cryptographically strong pseudo-random bytes
18*ebfedea0SLionel Sambucinto B<buf>. An error occurs if the PRNG has not been seeded with
19*ebfedea0SLionel Sambucenough randomness to ensure an unpredictable byte sequence.
20*ebfedea0SLionel Sambuc
21*ebfedea0SLionel SambucRAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>.
22*ebfedea0SLionel SambucPseudo-random byte sequences generated by RAND_pseudo_bytes() will be
23*ebfedea0SLionel Sambucunique if they are of sufficient length, but are not necessarily
24*ebfedea0SLionel Sambucunpredictable. They can be used for non-cryptographic purposes and for
25*ebfedea0SLionel Sambuccertain purposes in cryptographic protocols, but usually not for key
26*ebfedea0SLionel Sambucgeneration etc.
27*ebfedea0SLionel Sambuc
28*ebfedea0SLionel SambucThe contents of B<buf> is mixed into the entropy pool before retrieving
29*ebfedea0SLionel Sambucthe new pseudo-random bytes unless disabled at compile time (see FAQ).
30*ebfedea0SLionel Sambuc
31*ebfedea0SLionel Sambuc=head1 RETURN VALUES
32*ebfedea0SLionel Sambuc
33*ebfedea0SLionel SambucRAND_bytes() returns 1 on success, 0 otherwise. The error code can be
34*ebfedea0SLionel Sambucobtained by L<ERR_get_error(3)|ERR_get_error(3)>. RAND_pseudo_bytes() returns 1 if the
35*ebfedea0SLionel Sambucbytes generated are cryptographically strong, 0 otherwise. Both
36*ebfedea0SLionel Sambucfunctions return -1 if they are not supported by the current RAND
37*ebfedea0SLionel Sambucmethod.
38*ebfedea0SLionel Sambuc
39*ebfedea0SLionel Sambuc=head1 SEE ALSO
40*ebfedea0SLionel Sambuc
41*ebfedea0SLionel SambucL<rand(3)|rand(3)>, L<ERR_get_error(3)|ERR_get_error(3)>,
42*ebfedea0SLionel SambucL<RAND_add(3)|RAND_add(3)>
43*ebfedea0SLionel Sambuc
44*ebfedea0SLionel Sambuc=head1 HISTORY
45*ebfedea0SLionel Sambuc
46*ebfedea0SLionel SambucRAND_bytes() is available in all versions of SSLeay and OpenSSL.  It
47*ebfedea0SLionel Sambuchas a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
48*ebfedea0SLionel Sambucin OpenSSL 0.9.5.
49*ebfedea0SLionel Sambuc
50*ebfedea0SLionel Sambuc=cut
51